I've been trying to put together a login script that will account for XP
persistent drive mapping. I've foudn that with normal vbs scripting to
just remove and then remap a drive letter, that it may still appear to
be mapped incorrectly in My Computer.
All of the script that I have has come from other people.
Here is what I hve right now, and it is producing an error: Line 19
Char: 5 Error: Variable is undefined: 'HKCU'
----Start My Scrip-----------------------------------------------
Option Explicit
Dim objFSO, objNetwork, objReg
'*****************
'MAP Q: TO sever
'*****************
'
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
Set objReg =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
'Q: Drive
'*********
If (objFSO.DriveExists("Q:" = True)) Then
objNetwork.RemoveNetworkDrive "Q:", True, True
End If
If objFSO.DriveExists("Q:") Then
objReg.DeleteKey HKCU, "Network\" & Left("Q:", 1)
End If
objNetwork.MapNetworkDrive "Q:", "\\server\share"
---End My Script-----------------------------------------------
At one time, I had received this email/post with the script suggestions
below from a couple of people tryign to help. I'm not sure if all of
this is needed, or just part of it.
=======================================================================
To remove any persistent mappings, more may be necessary.
If (objFSO.DriveExists("j:" = True) Then
objNetwork.RemoveNetworkDrive "j:",True,True
End If
If objFSO.DriveExists("j:") Then
Set objReg =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
objReg.DeleteKey HKCU, "Network\" & Left("j:", 1)
Set objReg = Nothing
End If
--------------------------------------------------
Dim WshNet
Set WshNet = WScript.CreateObject("WScript.Network")
WshNet.RemoveNetworkDrive "J:", True, True
Wscript.Sleep(1000)
WshNet.MapNetworkDrive "J:", "\\myserver\users\shared"
Set WSHNet = Nothing
I put a 1 second delay in to allow the network to "settle" before the
reconnect. Might help??
---------------------------------------------------------
==========================================================================
Thanks for any help,
Mike
Bookmarks