Persistent map drive with VBScript



Hi there........

I'm trying to map drives with VBScript persistently so that even after
disconnect from network I will still see the mapped drives except they
will have an (X) disconnected.

I'm using the following, but can't seem to get it to work can anyone
please help............?



Function MapDrive(strDrive, strShare)
' Function to map network share to a drive letter.
' If the drive letter specified is already in use, the function
' attempts to remove the network connection.
' objFSO is the File System Object, with global scope.
' objNetwork is the Network object, with global scope.
' Returns True if drive mapped, False otherwise.

Dim objDrive

On Error Resume Next
If objFSO.DriveExists(strDrive) Then
Set objDrive = objFSO.GetDrive(strDrive)
If Err.Number <> 0 Then
On Error GoTo 0
MapDrive = False
Exit Function
End If
If CBool(objDrive.DriveType = 3) Then
objNetwork.RemoveNetworkDrive strDrive, True, True
Else
MapDrive = False
Exit Function
End If
Set objDrive = Nothing
End If
objNetwork.MapNetworkDrive strDrive, strShare
If Err.Number = 0 Then
MapDrive = True
Else
Err.Clear
MapDrive = False
End If
On Error GoTo 0
End Function

.



Relevant Pages

  • Re: Slow Startup
    ... then just click yes to disconnect those mapped drives. ... > But I had to reconnect because they are used to access some network ... However when I went to disconnect them they all gave me the ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: JPG Convert Question
    ... > cmyk color mode settings in adobe illustrator to export tp jpg. ... > over the network. ... >> mapped drives, though there can be issues with some network clients/servers. ...
    (microsoft.public.powerpoint)
  • RE: Mapped drives say DIsconnected and cannot disconnect them
    ... Test it in Safe Mode with Network ... some mapped drives listed in the registry keys. ... Disconnect mapped drives it says there ...
    (microsoft.public.windows.file_system)
  • Re: Very slow response when changing directories during "save as"
    ... I have a laptop that is not always on the network and would like to connect ... the batch file for connecting? ... on Disconnect Network Drive, and disconnect any mapped drives that are ...
    (microsoft.public.office.misc)
  • Re: Long delay to find the other computer on network
    ... >>I have a simple 2 computer home network set up with a crossover cable. ... but it is very slow to find the W98 ... explorer trying to find the "missing" drives. ... So I removed the mapped drives ...
    (microsoft.public.windowsxp.network_web)