Daniel
December 17th 03, 10:21 PM
My customer has a network with about 25 XP Pro boxes with
a Win2K DC. All boxes are fully updated. All clients are
Dell Dim 4600s (identical builds/hardware). I have the
following logon script in \\somesrv\netlogon which also
appears in \\somesrv\SYSVOL\foo.com\scripts. Each user
account has login.bat listed in their user profile. 4
boxes would almost never map the drives upon boot.
Running the script manually after login worked fine. I
added the login script to the Group Policy of the user
container and now 2 of the boxes work fine. However, the
other 2, while working more often, are still having
regular problems mapping. Any thoughts?
On Error Resume Next
Dim WSHNetwork, WshShell, WshProcessEnvironment, UserObj
Dim strUserID, strDomain, strWorkstation, WshSysEnv, sNIC,
sMan
Dim iCount, strOS, strTarget, strSource
Set WSHNetwork = Wscript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshProcessEnvironment = WshShell.Environment("Process")
Set DomainObj = GetObject("WinNT://HTACONSULTING")
Set FileSysObj = CreateObject("Scripting.FileSystemObject")
strDomain = "HTACONSULTING"
strUserID = ""
'----------------------------------------------------------
-
' Wait for the DC to return the username
Do While strUserID = ""
strUserID = WSHNetwork.UserName
Loop
'----------------------------------------------------------
-
' Populate array of group memberships
Set UserObj = GetObject("WinNT://" & strDomain & "/" &
strUserID)
Dim UserGroups
Dim GroupObj
UserGroups=""
For Each GroupObj In UserObj.Groups
UserGroups=UserGroups & "[" & GroupObj.Name & "]"
Next
'----------------------------------------------------------
--
' Map user and common drives
KillDrive("H:")
MapDrive "H:","\\mailsrv\Common"
KillDrive("I:")
MapDrive "I:","\\mailsrv\Users"
KillDrive("J:")
MapDrive "J:","\\mailsrv\Archives"
'----------------------------------------------------------
--
' Map drives based on group membership
If InGroup("HTA Billing") Then
KillDrive("K:")
MapDrive "K:","\\printsrv\TrackIT"
End If
If InGroup("Domain Admins") Then
KillDrive("L:")
MapDrive "L:","\\mailsrv\Netlogon"
End If
If InGroup("Domain Admins") Then
KillDrive("Q:") 'M: drive is used on Exchange Server for
Mail Store
MapDrive "Q:","\\mailsrv\Htadmin"
End IF
If InGroup("HTA Accounting") Then
KillDrive("N:")
MapDrive "N:","\\mailsrv\Accounting"
End If
If InGroup("HTA Management") Then
KillDrive("O:")
MapDrive "O:","\\mailsrv\Management"
End If
If InGroup("HTA HR") Then
KillDrive("P:")
MapDrive "P:","\\mailsrv\HR"
End If
'----------------------------------------------------------
--
' SUBROUTINES
'-----------------------
' Unmap currently mapped drives
Sub KillDrive(strdrive)
On Error Resume Next
If FileSysObj.DriveExists(strDrive) = true then
WshNetwork.RemoveNetworkDrive strDrive
End If
End Sub
'-----------------------
' Map 'em baby!
Sub MapDrive( strDrive, strShare )
Dim Path
If InStr(strShare,"\") then
Path=strShare
Else
Path="\\" & Authsvr & "\" & strShare
End If
' Map drive
On Error Resume Next
WSHNetwork.MapNetworkDrive strDrive, Path
' End Sub result
If Err.Number <> 0 Then WriteErr( strUserID & ":
Mapping " & strDrive & " to " & Path & " " &
Err.Description & " " & Now() )
End Sub
'----------------------------------------------------------
--
' FUNCTIONS
'-----------------------
' Group checking
Function InGroup(strGroup)
InGroup=False
If InStr(UserGroups,"[" & strGroup & "]") Then
InGroup=True
End If
End Function
Thanks,
Daniel
a Win2K DC. All boxes are fully updated. All clients are
Dell Dim 4600s (identical builds/hardware). I have the
following logon script in \\somesrv\netlogon which also
appears in \\somesrv\SYSVOL\foo.com\scripts. Each user
account has login.bat listed in their user profile. 4
boxes would almost never map the drives upon boot.
Running the script manually after login worked fine. I
added the login script to the Group Policy of the user
container and now 2 of the boxes work fine. However, the
other 2, while working more often, are still having
regular problems mapping. Any thoughts?
On Error Resume Next
Dim WSHNetwork, WshShell, WshProcessEnvironment, UserObj
Dim strUserID, strDomain, strWorkstation, WshSysEnv, sNIC,
sMan
Dim iCount, strOS, strTarget, strSource
Set WSHNetwork = Wscript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshProcessEnvironment = WshShell.Environment("Process")
Set DomainObj = GetObject("WinNT://HTACONSULTING")
Set FileSysObj = CreateObject("Scripting.FileSystemObject")
strDomain = "HTACONSULTING"
strUserID = ""
'----------------------------------------------------------
-
' Wait for the DC to return the username
Do While strUserID = ""
strUserID = WSHNetwork.UserName
Loop
'----------------------------------------------------------
-
' Populate array of group memberships
Set UserObj = GetObject("WinNT://" & strDomain & "/" &
strUserID)
Dim UserGroups
Dim GroupObj
UserGroups=""
For Each GroupObj In UserObj.Groups
UserGroups=UserGroups & "[" & GroupObj.Name & "]"
Next
'----------------------------------------------------------
--
' Map user and common drives
KillDrive("H:")
MapDrive "H:","\\mailsrv\Common"
KillDrive("I:")
MapDrive "I:","\\mailsrv\Users"
KillDrive("J:")
MapDrive "J:","\\mailsrv\Archives"
'----------------------------------------------------------
--
' Map drives based on group membership
If InGroup("HTA Billing") Then
KillDrive("K:")
MapDrive "K:","\\printsrv\TrackIT"
End If
If InGroup("Domain Admins") Then
KillDrive("L:")
MapDrive "L:","\\mailsrv\Netlogon"
End If
If InGroup("Domain Admins") Then
KillDrive("Q:") 'M: drive is used on Exchange Server for
Mail Store
MapDrive "Q:","\\mailsrv\Htadmin"
End IF
If InGroup("HTA Accounting") Then
KillDrive("N:")
MapDrive "N:","\\mailsrv\Accounting"
End If
If InGroup("HTA Management") Then
KillDrive("O:")
MapDrive "O:","\\mailsrv\Management"
End If
If InGroup("HTA HR") Then
KillDrive("P:")
MapDrive "P:","\\mailsrv\HR"
End If
'----------------------------------------------------------
--
' SUBROUTINES
'-----------------------
' Unmap currently mapped drives
Sub KillDrive(strdrive)
On Error Resume Next
If FileSysObj.DriveExists(strDrive) = true then
WshNetwork.RemoveNetworkDrive strDrive
End If
End Sub
'-----------------------
' Map 'em baby!
Sub MapDrive( strDrive, strShare )
Dim Path
If InStr(strShare,"\") then
Path=strShare
Else
Path="\\" & Authsvr & "\" & strShare
End If
' Map drive
On Error Resume Next
WSHNetwork.MapNetworkDrive strDrive, Path
' End Sub result
If Err.Number <> 0 Then WriteErr( strUserID & ":
Mapping " & strDrive & " to " & Path & " " &
Err.Description & " " & Now() )
End Sub
'----------------------------------------------------------
--
' FUNCTIONS
'-----------------------
' Group checking
Function InGroup(strGroup)
InGroup=False
If InStr(UserGroups,"[" & strGroup & "]") Then
InGroup=True
End If
End Function
Thanks,
Daniel