Downloaded since I suck as scripting and like GUI(s). I have one issue where a vendor installed their application via a hidden IPC share, so \\server\app$
This is for a specific group and here's what the GUI gave me
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically grab the user's domain name
DomainString = Wshnetwork.UserDomain
'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
'Map drives needed by all users
WSHNetwork.RemoveNetworkDrive "M:", True, True
WSHNetwork.MapNetworkDrive "M:", "\\co-fs1\Departments",True
WSHNetwork.RemoveNetworkDrive "U:", True, True
WSHNetwork.MapNetworkDrive "U:", "\\co-fs1\" & UserString,True
'Now check for group memberships and map appropriate drives
'Note that this checks Global Groups and not domain local groups.
For Each GroupObj In UserObj.Groups
'Force upper case comparison of the group names, otherwise this is case sensitive.
Select Case UCase(GroupObj.Name)
Case "CENTRAL OFFICE"
WSHNetwork.RemoveNetworkDrive "O:", True, True
WSHNetwork.MapNetworkDrive "O:", "\\co-fs1\Apps", True
Case "FOOD SERVICE"
WSHNetwork.RemoveNetworkDrive "X:", True, True
WSHNetwork.MapNetworkDrive "X:", "\\lunch-fs1\horizon$", True
End Select
Next
End Select
Next
'Synchronise PC's time with server
WSHShell.Run "net time /domain:" & DomainString & " /set /yes", 0, TRUE
'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
Wscript.Quit
With it this way, I get a scripting error at login. How would I fix this?
Thanks.
This is for a specific group and here's what the GUI gave me
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically grab the user's domain name
DomainString = Wshnetwork.UserDomain
'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
'Map drives needed by all users
WSHNetwork.RemoveNetworkDrive "M:", True, True
WSHNetwork.MapNetworkDrive "M:", "\\co-fs1\Departments",True
WSHNetwork.RemoveNetworkDrive "U:", True, True
WSHNetwork.MapNetworkDrive "U:", "\\co-fs1\" & UserString,True
'Now check for group memberships and map appropriate drives
'Note that this checks Global Groups and not domain local groups.
For Each GroupObj In UserObj.Groups
'Force upper case comparison of the group names, otherwise this is case sensitive.
Select Case UCase(GroupObj.Name)
Case "CENTRAL OFFICE"
WSHNetwork.RemoveNetworkDrive "O:", True, True
WSHNetwork.MapNetworkDrive "O:", "\\co-fs1\Apps", True
Case "FOOD SERVICE"
WSHNetwork.RemoveNetworkDrive "X:", True, True
WSHNetwork.MapNetworkDrive "X:", "\\lunch-fs1\horizon$", True
End Select
Next
End Select
Next
'Synchronise PC's time with server
WSHShell.Run "net time /domain:" & DomainString & " /set /yes", 0, TRUE
'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
Wscript.Quit
With it this way, I get a scripting error at login. How would I fix this?
Thanks.