I've been trying to write a simple logon script for a Server 2003/XP
workstation environment.
At this point, I'm past trying anything fancy such as mapping by group
membership, I just want to have everyone map to the same few drives, but
I've run into a problem.
Say someone already has a drive, J:, mapped through XP set to Reconnect.
In my logon script, I have:
wshNetwork.RemoveNetworkDrive "j:"
wshNetwork.MapNetworkDrive "j:","\\myserver\users\shared"
J: is already mapped to something else in XP. The script would not
Remove the drive first. I captured this error "The local device name has
a remembered connection to another network resource." So, since XP is
set to remember the connection, this will not remove it.
I found this information somewhere:
"In addition to the mandatory parameter that specifies the mapped drive
to be removed, the MapNetworkDrive method accepts two additional,
optional, parameters: A Boolean value that, if set to True, specifies
that the method should unmap the drive regardless of whether it is
currently in use. If the value is set to True, the user will no longer
be able to save data to that drive, even if he or she has already opened
a document from there. Instead, the user will have to save the document
to an alternate location.A Boolean value that, if set to True, specifies
that the method should remove the drive mapping from the profile of the
user."
So, I tried this:
wshNetwork.RemoveNetworkDrive "j:",True,True
But it doesnt' work either - it doesn't produce an error, but it doesn't
unmap the drive either.
If I issue a Net Use from the command line, it shows it mapped correctly
there, but My Computer still shows the old mapping - so I guess it's cached.
Can anyone tell me how to over come this? All I want to do is:
1)Check if a drive letter is already mapped to something, if so, unmap it.
2)Map the drive to something new.
3)Have the new mapping correctly displayed in My Computer.
Thanks,
Mike
Bookmarks