Persistent map drive with VBScript
- From: "Star" <momo2804@xxxxxxxxx>
- Date: 15 Jan 2007 08:59:55 -0800
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
.
- Prev by Date: Excel script - corrections?
- Next by Date: Re: sending all mail in a folder.
- Previous by thread: Excel script - corrections?
- Next by thread: Re: sending all mail in a folder.
- Index(es):
Relevant Pages
|