Link to home
Start Free TrialLog in
Avatar of jjohnson502
jjohnson502

asked on

Client User Logon Script wont load in Windows 7

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
Avatar of SerhiyKo
SerhiyKo

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.
Avatar of Dontmilkthis
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.
ASKER CERTIFIED SOLUTION
Avatar of Martin Kühn
Martin Kühn
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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