Mapped Drives not persistent when mapped from logon script

I have the attached vbs logon script being called by logon.bat. I have a 2003 Server running AD and clients are XP SP2. I can logon and the script runs no problem. My drives are mapped. However, they are not persistent. If I log into Windows, then manually run the script the drives mapped and are persistent. Any thoughts would be greatly appreciated.

' MCMAPDRIVE.vbs - maps drives for users based on group membership
Dim objNet, strUserName 
Dim FileSysObj
On Error Resume Next
'Check the local ComputerName and run only if it's not a citrix server
'Set WshNetwork = WScript.CreateObject("WScript.Network")
'strSysEnvCN = WshNetwork.ComputerName 
'bolWTS =  InStr(strSysEnvCN, "JERMC6") 
  Set objNet = CreateObject("Wscript.Network") 
  set FileSysObj = CreateObject("Scripting.FileSystemObject")
  strUserName =objNet.UserName 
  set UserObj = GetObject("WinNT://" & objNet.UserDomain & "/" & objNet.UserName)
  For Each Group In UserObj.groups
     Select Case Group.Name
        Case "_Marketing" '80
		   MapDrive "m:", "", "marketing"
	Case "_Implementation"
           MapDrive "p:", "", "nsfforms"
        Case "_HR"
           MapDrive "r:", "", "hr"
        Case "_InternalIT"
           MapDrive "t:", "", "internalIT"
        Case "_Executives"
           MapDrive "x:", "", "executives"
        Case "_Finance"
           MapDrive "y:", "", "finance"
        Case "_Accounting"
           MapDrive "z:", "", "accounting"
     End Select
  'Call DisplayMappings
'End If
Sub MapDrive(Drive, FileServer, Share) '180
     FileServer = "\\" & FileServer
     Share = "\" & Share
     MapCount = MapCount + 1
  'Wscript.Echo "Now Mapping " & Drive & " to " & FileServer & Share
  If FileSysObj.DriveExists(Drive) = True Then
    objNet.RemoveNetworkDrive Drive, True, True
  End If
  objNet.MapNetworkDrive Drive, FileServer & Share & ", True"
End Sub
Sub DisplayMappings()
     Set DriveCollection = objNet.EnumNetworkDrives
     MsgString = "You have access to following network " & vbcrlf & "drive connections: " & vbCRLF & vbCRLF
     For i = 0 To DriveCollection.Count - 1 Step 2
          MsgString = MsgString & vbCRLF & vbtab & DriveCollection(i) & Chr(9) & DriveCollection(i + 1)
     MsgBox MsgString,vbInformation,"Your Information Technology"
End Sub     

Open in new window

Who is Participating?
ee_autoConnect With a Mentor Commented:
Question PAQ'd, 500 points refunded, and stored in the solution database.
The third parameter of MapDrive needs to be a boolean, not a string.

Change to:

objNet.MapNetworkDrive Drive, FileServer & Share, True
Sorry, I meant MapNetworkDrive.  But you get the point.
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

mwarstlerAuthor Commented:

Thanks for your quick response. I'll test in the morning and reply.

mwarstlerAuthor Commented:
I'm having the same problem. If I log into Windows and run the script the drives are persistent. If I run it as a logon script they are not persistent. I've also tried this with the same results.

Set SH = CreateObject("WScript.Shell")
Set FileSysObj = CreateObject("Scripting.FileSystemObject")
SH.Run "NET USE " & Drive & " /delete"
SH.Run "NET USE " & Drive & " " & FileServer & Share & " /Persistent:YES"
'Wscript.Echo "net use " & Drive & " " & FileServer & Share & " /Persistent:YES"
A potentially obvious question for both of you:

If you have the drive mappings in a logon script, why do you need them to be persistent?  They'll re-map each time you log on.

If you're saying that they're not persistent because you are logging in to a different user profile that doesn't run the script.. well, yeah, they wouldn't be.
mwarstlerAuthor Commented:
My laptop users need them to be mapped when they go home and VPN into the office
when they go home, do they log in to their domain account or a local account on the machine?
mwarstlerAuthor Commented:
They log into thier domain account
mwarstlerAuthor Commented:
The solution was to only call the vbs scipt directly and not via logon.bat
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.