Advertisement

05.27.2008 at 08:11AM PDT, ID: 23435088
[x]
Attachment Details

2003 Active directory vb  login script does not  always execute.

Asked by DrewBryant1961 in Active Directory

Tags: , , ,

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.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
'==========================================================================
'
' 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
[+][-]05.27.2008 at 12:58PM PDT, ID: 21655129

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 05:44PM PDT, ID: 21656868

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 05:47PM PDT, ID: 21656878

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 03:18AM PDT, ID: 21659063

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Directory
Tags: Microsoft, 2003 Server Active DIrectory, 2003, Issues with vbscript login script
Sign Up Now!
Solution Provided By: Paka
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628