Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon script mapping some drives not all

Status
Not open for further replies.

HJBPS

Programmer
Apr 25, 2008
8
US
I have a logon script used for mapping drives.
It maps drives based on groups. The logon script maps 3 of the 4 drives. It does not map the 4th drive. When I run the script after logging on it does map this 4th drive but does not do it while logging on.
Anyone have a solution for this. PLEASE HELP, thanks.
 
The script is below. The X drive mapping does not happen when you log in. After logging in, if you run the logging script, it maps the drive.
I checked the share settings and security settings on that share and all seem ok. They have to be since it maps post login.


ON ERROR RESUME NEXT

' Option Explicit
Dim WSHShell, WSHNetwork, DomainString, objDomain, UserString, UserObj, strComputer, WinDir, GroupObj
Dim Ugroup, objDrives, i
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objDomain = getObject("LDAP://rootDse")
Set objDrives = WSHNetwork.EnumNetworkDrives
DomainString = objDomain.Get("dnsHostName")

'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

' Install All Printers
WSHNetwork.AddWindowsPrinterConnection "\\bps-dc\Canon iR7095"
WSHNetwork.AddWindowsPrinterConnection "\\bps_mm_srv1\Canon iR5000-PCL"
WSHNetwork.AddWindowsPrinterConnection "\\bps_mm_srv1\HP LaserJet 4200 PCL 6 (Barb)"

For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
Case "BPS"
WSHNetwork.AddWindowsPrinterConnection "\\bps_mm_srv1\HP LaserJet 5Si"
WSHNetwork.AddWindowsPrinterConnection "\\bps_mm_srv1\BPSACCT"
DriveMapper "I:", "\\bps-nas\Company Software"
DriveMapper"Q:", "\\BPS_MM_srv3\apps"
DriveMapper"V:", "\\bps_mm_srv3\BPSData"
Case "M&M"
WSHNetwork.AddWindowsPrinterConnection "\\bps_mm_srv1\HP Color LaserJet 8550 PCL 5C"
WSHNetwork.AddWindowsPrinterConnection "\\bps_mm_srv1\HP LaserJet 4100 Series PCL"
WSHNetwork.AddWindowsPrinterConnection "\\bps_mm_srv1\HP LaserJet 9000 PCL 6"
DriveMapper"X:", "\\MM-PFX\Pacs"
DriveMapper"W:", "\\BPS_MM_srv3\MMData"
DriveMapper"I:", "\\bps-nas\Company Software"
DriveMapper"P:", "\\BPS_MM_srv5\tax"
DriveMapper"Q:", "\\BPS_MM_srv3\apps"
DriveMapper"T:", "\\BPS_MM_srv3\appdata"
End Select
Next

Sub DriveMapper(Drive, Share)
For i = 0 to objDrives.Count - 1
'Wscript.Echo Drive
'Wscript.Echo Mapped
IF objDrives.Item(i) = Drive THEN WSHNetwork.RemoveNetworkDrive Drive, TRUE, TRUE
NEXT
WSHNetwork.MapNetworkDrive Drive, Share, true

End Sub

WSHNetwork.MapNetworkDrive "X:", "\\MM-PFX\Pacs", true


'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set objDomain = Nothing
Set UserString = Nothing
Set strComputer = Nothing
Set UGroup = Nothing
Set objDrives = Nothing
Set i = Nothing

WScript.Quit
 
Perhaps just a timing issue. Try adding the following above the line to map the x drive.

Wscript.Sleep 500



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top