Client User Logon Script wont load in Windows 7

jjohnson502
jjohnson502 used Ask the Experts™
on
Having issues loading a startup script in Windows 7. It basically assigns a netwrok drive based on the security group you are associatd with. I cant get this to load on any windows 7 machine. If i manually lauch it, it works just fine. Any ideas?

On Error Resume Next
 
Set WshNetwork = CreateObject("WScript.Network")
 
DomainString = WshNetwork.UserDomain
UserString = WshNetwork.UserName
 
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
 
'unmap all drives
WshNetwork.RemoveNetworkDrive "m:",true,true
WshNetwork.RemoveNetworkDrive "n:",true,true
WshNetwork.RemoveNetworkDrive "o:",true,true
WshNetwork.RemoveNetworkDrive "p:",true,true
WshNetwork.RemoveNetworkDrive "q:",true,true
WshNetwork.RemoveNetworkDrive "s:",true,true
WshNetwork.RemoveNetworkDrive "u:",true,true
WshNetwork.RemoveNetworkDrive "W:",true,true
WshNetwork.RemoveNetworkDrive "z:",true,true

 
 
For Each GroupObject In UserObj.Groups
      Select Case GroupObject.Name
            Case "ADMIN"
                  WshNetwork.MapNetworkDrive "z:", "\\server\ADMIN"
            Case "MANAGEMENT"
                  WshNetwork.MapNetworkDrive "m:", "\\server\MANAGEMENT"
            Case "OFFICE"
                  WshNetwork.MapNetworkDrive "o:", "\\server\OFFICE"
            Case "SALES"
                  WshNetwork.MapNetworkDrive "s:", "\\server\SALES"
            Case "QUALITY"
                  WshNetwork.MapNetworkDrive "q:", "\\server\QUALITY"
      

      End Select

Next


Set objNetwork = Wscript.CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\server\Brother"
objNetwork.AddWindowsPrinterConnection "\\server\Brother2"
objNetwork.AddWindowsPrinterConnection "\\server\HP"
objNetwork.AddWindowsPrinterConnection "\\server\Kyocera"
objNetwork.SetDefaultPrinter ("\\server\Kyocera")

WScript.Quit
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
I would try using Cscript instead of Wscript. Cscript is more suitable for CLI scripting.

On a side not, I found that Windows 7 has great Group Policies for mapping drives.
I would have the logon script launch from a batch file. after calling the script with cscript, add a Pause command so the window will stay visible and you can see any output it has generated.

Additionally, I'm with SerhiyKo, if all your doing is mapping drives and printer(s) based on security groups, group preferences are a much easier option.
System Administrator
Commented:
Do you have 2008DC? Then I would prefer 'Preferences' under Groupplicy Management.
Lee OsborneSenior Infrastructure Engineer

Commented:
We've just rolled out Windows 7 on our domain and have moved from batch and vb logon scripts, to GP drive mapping etc. It's much easier to manage and assign drives etc. based on many different criteria for the user and/or the workstation.

Lee

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial