User = "domain\username" ' the user name you want to use for mapping the network drive
Password = "Password123" 'the password for the above user
LocalDrive = "S:"
RemoteShare = "\\servername\FolderName"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
'Unmap the drive (optional)
If(ObjFSO.DriveExists(LocalDrive)) Then
objNetwork.RemoveNetworkDrive LocalDrive, True, True
End If
'Map the drive command
objNetwork.MapNetworkDrive LocalDrive, RemoteShare, True, User, Password
Set objNetwork = Nothing
Set objFSO = Nothing
No comments:
Post a Comment