Hello. I have a login script and I would like to rename the network drives once they are mapped. Can someone assist me with this?? The script is pasted below. Thank you in advance for any assistance.
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
'Find the Windows Directory
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
'Map public drive for ALL
wshNetwork.MapNetworkDrive "p:", "\\usacpuila4\public"
wshNetwork.MapNetworkDrive "t:", "\\engineering\Engineering"
wshNetwork.MapNetworkDrive "q:", "\\engineering\Technical-Services"
wshNetwork.MapNetworkDrive "s:", "\\sales\sales"
wshNetwork.MapNetworkDrive "o:", "\\usacpuila5\corporate"
wshNetwork.MapNetworkDrive "m:", "\\sales\marketing"
wshNetwork.MapNetworkDrive "n:", "\\usacpuila5\accounting"
wshNetwork.MapNetworkDrive "r:", "\\usacpuila5\human-resources"
wshNetwork.MapNetworkDrive "v:", "\\engineering\parts"
wshNetwork.MapNetworkDrive "w:"' "\\usacpuila5\information-systems"
For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
'Check for group memberships and take needed action
Case "MOCGRPIT"
wshNetwork.MapNetworkDrive "U:", "\\usacpuila5\information systems-users\" & wshNetwork.UserName
Case "MOCGRPAPPLICATIONS"
WshNetwork.MapNetworkDrive "U:", "\\engineering\Applications-Users\" & wshNetwork.Username
Case "MOCGRPSALES"
wshNetwork.MapNetworkDrive "U:", "\\sales\Sales-Users\" & wshNetwork.UserName
Case "MOCGRPHR"
wshNetwork.MapNetworkDrive "U:", "\\usacpuila5\Human-Resources-Users\" & wshnetwork.Username
Case "MOCGRPSERVICE"
wshNetwork.MapNetworkDrive "U:", "\\engineering\Service-users\" & wshNetwork.Username
Case "MOCGRPACCOUNTING"
wshNetwork.MapnetworkDrive "U:", "\\usacpuila5\Accounting-Users\" & wshNetwork.Username
Case "MOCGRPCORPORATE"
wshNetwork.MapNetworkDrive "U:", "\\usacpuila5\Corporate-Users\" & wshNetwork.Username
Case "MOCGRPPARTS"
wshNetwork.MapNetworkDrive "u:", "\\engineering\parts-users\" & wshNetwork.Username
Case "MOCGRPMARKETING"
wshNetwork.MapNetworkDrive "U:", "\\sales\Marketing-Users\" & wshNetwork.Username
End Select
Next
wscript.quit
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
'Find the Windows Directory
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
'Map public drive for ALL
wshNetwork.MapNetworkDrive "p:", "\\usacpuila4\public"
wshNetwork.MapNetworkDrive "t:", "\\engineering\Engineering"
wshNetwork.MapNetworkDrive "q:", "\\engineering\Technical-Services"
wshNetwork.MapNetworkDrive "s:", "\\sales\sales"
wshNetwork.MapNetworkDrive "o:", "\\usacpuila5\corporate"
wshNetwork.MapNetworkDrive "m:", "\\sales\marketing"
wshNetwork.MapNetworkDrive "n:", "\\usacpuila5\accounting"
wshNetwork.MapNetworkDrive "r:", "\\usacpuila5\human-resources"
wshNetwork.MapNetworkDrive "v:", "\\engineering\parts"
wshNetwork.MapNetworkDrive "w:"' "\\usacpuila5\information-systems"
For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
'Check for group memberships and take needed action
Case "MOCGRPIT"
wshNetwork.MapNetworkDrive "U:", "\\usacpuila5\information systems-users\" & wshNetwork.UserName
Case "MOCGRPAPPLICATIONS"
WshNetwork.MapNetworkDrive "U:", "\\engineering\Applications-Users\" & wshNetwork.Username
Case "MOCGRPSALES"
wshNetwork.MapNetworkDrive "U:", "\\sales\Sales-Users\" & wshNetwork.UserName
Case "MOCGRPHR"
wshNetwork.MapNetworkDrive "U:", "\\usacpuila5\Human-Resources-Users\" & wshnetwork.Username
Case "MOCGRPSERVICE"
wshNetwork.MapNetworkDrive "U:", "\\engineering\Service-users\" & wshNetwork.Username
Case "MOCGRPACCOUNTING"
wshNetwork.MapnetworkDrive "U:", "\\usacpuila5\Accounting-Users\" & wshNetwork.Username
Case "MOCGRPCORPORATE"
wshNetwork.MapNetworkDrive "U:", "\\usacpuila5\Corporate-Users\" & wshNetwork.Username
Case "MOCGRPPARTS"
wshNetwork.MapNetworkDrive "u:", "\\engineering\parts-users\" & wshNetwork.Username
Case "MOCGRPMARKETING"
wshNetwork.MapNetworkDrive "U:", "\\sales\Marketing-Users\" & wshNetwork.Username
End Select
Next
wscript.quit