troubleshooting Question

2003 Active directory vb login script does not always execute.

Avatar of DrewBryant1961
DrewBryant1961 asked on
Active Directory
5 Comments1 Solution1899 ViewsLast Modified:
Hello:

I have a Windows 2003 domain (one forest, one domain) that I am working on a vb login script to map drives based on group membership. Client pcs are Windows XP. Currently, drives are statically mapped to a server share; the users home folder is mapped via ADUC.

I used an existing script (script below) I found on the web and modified it to suit my environment. The script deletes drive mappings and remaps them based on whether they are members of a global group.

Right now the script is linked as a GPO to an OU with a single user account.

I have 3 issues/questions.

1.      The script does not always run. I can execute it from a command prompt without error. It runs sometimes, but not always.
2.      When it does run, it is slow. There is a 30 second delay from the time the items in the startup group load to the time the mapped drives are listed.
3.      When I modifying the script, I added a piece of code to overlay the OS and patch level over the system tray. I thought it might be something I wanted to use. I didnt care for it, so I removed this piece of code from the login script, posted the updated script in GPMC and rebooted the client pc. The overlay is still there. Ran a gpupdate /force from the client; still there. Where is this being executed from?

Windows Version Overlay Add On

'Configure the PC to show the Windows Version and Service Pack as an overlay to the desktop above the System Tray
'=====================================
HKEY_CURRENT_USER = &H80000001
strComputer = WSHNetwork.Computername
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Control Panel\Desktop"
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
ValueName = "PaintDesktopVersion"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, dwValue

Login script is attached.

All responses appreciated as I am new to scripting.
'==========================================================================
'
' NAME: LoginScript.vbs
'
' AUTHOR:  Mark D. MacLachlan, The Spider's Parlor
' URL   : http://www.thespidersparlor.com
' Copyright (c) 2003-2007
' DATE  : 4/10/2003
'
' COMMENT: Enumerates current users' group memberships in given domain.
'          Maps and disconnects drives. 
'
'==========================================================================
 
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
 
'Disconnect any drive mappings as needed.
WSHNetwork.RemoveNetworkDrive "H:", True, True
WSHNetwork.RemoveNetworkDrive "J:", True, True
WSHNetwork.RemoveNetworkDrive "K:", True, True
WSHNetwork.RemoveNetworkDrive "M:", True, True
WSHNetwork.RemoveNetworkDrive "P:", True, True
WSHNetwork.RemoveNetworkDrive "Q:", True, True
WSHNetwork.RemoveNetworkDrive "R:", True, True
WSHNetwork.RemoveNetworkDrive "S:", True, True
WSHNetwork.RemoveNetworkDrive "T:", True, True
WSHNetwork.RemoveNetworkDrive "U:", True, True
 
'Give the PC time to do the disconnect, wait 200 milliseconds
wscript.sleep 200
 
'Map drives needed by all
'Note the first command uses the user name as a variable to map to a user share.
'WSHNetwork.MapNetworkDrive "H:", "\\server\users\" & UserString,True
WSHNetwork.MapNetworkDrive "S:", "\\nas\scratch",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)
    'Check for group memberships and take needed action
    'In this example below, ADMIN and WORKERB are groups.
    'Note the use of all upper case letters as mentioned above.
    'Note also that the groups must be Global Groups.
 
        Case "MEETINGS"
            WSHNetwork.MapNetworkDrive "h:", "\\nas\meetings",True
        Case "DEBT"
            WSHNetwork.MapNetworkDrive "j:", "\\nas\superdebt",True
            WSHNetwork.MapNetworkDrive "m:", "\\nas\superdebt\Mip2006",True
        Case "IMIS"
            WSHNetwork.MapNetworkDrive "k:", "\\nas\imis\reports",True
        Case "DORN"
            WSHNetwork.MapNetworkDrive "m:", "\\nas\dorn",True
        Case "SALARY"
            WSHNetwork.MapNetworkDrive "p:", "\\nas\salary",True
        Case "LEGTRACKING"
            WSHNetwork.MapNetworkDrive "q:", "\\nas\winleg",True
        Case "WAGESALARY"
            WSHNetwork.MapNetworkDrive "r:", "\\nas\wagescac",True
        Case "ATTORNEYS"
            WSHNetwork.MapNetworkDrive "t:", "\\nas\attorney",True
        Case "INSURANCE"
            WSHNetwork.MapNetworkDrive "u:", "\\nas\insurance",True
      End Select
Next
 
' This section of script will prevent the balloon window
' that appears when printing to a network shared printer
' after XP Service Pack 2 is installed.
'=====================================
 
Path = "HKCU\Printers\Settings\EnableBalloonNotificationsRemote"
WshShell.RegWrite Path, 0 ,"REG_DWORD"
 
'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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros