Windows 7 and Network Drive Mapping

Status
Not open for further replies.

Osiris

Golden Master
Messages
36,817
Location
Kentucky
I can't seem to figure out yet as to why the network drives aren't mapping so here is a VB script to map them manually. If you dont need the output message simply remove it. Replace the drive letters with the ones you need, etc.

Code:
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "R:", "[URL="file://servername/DShares"][COLOR=#0066cc]\\servername\DShares[/COLOR][/URL]" 
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "N:", "[URL="file://servername/DShares/SAP"][COLOR=#0066cc]\\servername\DShares\SAP[/COLOR][/URL]" 
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "S:", "[URL="file://servername/GShares"][COLOR=#0066cc]\\servername\GShares[/COLOR][/URL]" 
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "Q:", "[URL="file://servername/QS9000"][COLOR=#0066cc]\\servername\QS9000[/COLOR][/URL]" 
 
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "X:", "[URL="file://servername/Network_Scanning"][COLOR=#0066cc]\\servername\Network_Scanning[/COLOR][/URL]" 
On Error Resume Next
Dim strDriveLetter, strRemotePath, strUserName
strDriveLetter = "H:" 
strRemotePath = "[URL="file://servername/"][COLOR=#0066cc]\\servername\[/COLOR][/URL]" 
' Purpose of script to create a network object. (objNetwork)
' Then apply the MapNetworkDrive method. Result H: drive
Set objNetwork = WScript.CreateObject("WScript.Network") 
' Here is where we extract the UserName
strUserName = objNetwork.UserName 
strUserName = strUserName & "$"
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath & strUserName 
 
msgbox ("Drives Have Been Successfully Mapped")
 
Status
Not open for further replies.
Back
Top Bottom