Computing.Net > Forums > Windows 2000 > Can't get mapped drive to disconnec

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Can't get mapped drive to disconnec

Reply to Message Icon

Name: Togo33
Date: February 12, 2004 at 07:38:01 Pacific
OS: Windows 2000
CPU/Ram: 3.06 1GB
Comment:

Howdy, I'm having some trouble with getting my logon script to disconnect M: from it's current mapping and then reconnect M: drive to it's new destination. My logon script is as follows;


Set WshShell = WScript.CreateObject("WScript.Shell")


' set the variables.

Set CofNet = WScript.CreateObject("WScript.Network")
Set CheckDrive = CofNet.EnumNetworkDrives()

DriveLetter = "M:"

RemotePath = "\\10.10.10.20\City_Sds"

' For ... Next loop

AlreadyConnected = False
For i = 0 To CheckDrive.Count - 1 Step 2
If CheckDrive.Item(i) = DriveLetter Then AlreadyConnected = True
Next

' If = then, else
' This section tests to see if the Drive is already mapped, and if yes then to disconnect


If AlreadyConnected = True then
CofNet.RemoveNetworkDrive DriveLetter
CofNet.MapNetworkDrive DriveLetter, RemotePath
WshShell.PopUp "Drive " & DriveLetter & "Disconnected, then connected successfully."

Else
CofNet.MapNetworkDrive DriveLetter, RemotePath
WshShell.PopUp "Drive " & DriveLetter & " connected successfully."

End if

It works great if there is no drive mapped to M: or if the drive mapped to M: was connected via logon script. However if the M: drive was mapped on the local computer and the reconnect at logon box checked the script will disconnect M: and then give the following error when trying to remap M: to it's new location;


Windows Script Host
An attempt was made to remember a device that had previously been remembered.

I've also tried this with the net use /d in a batch file and the same thing happens.

Any ideas? Thanks in advance

Thanks,
Tony


Thanks,
Tony



Sponsored Link
Ads by Google

Response Number 1
Name: Lucid
Date: February 13, 2004 at 14:41:27 Pacific
Reply:

If either one of those isn't working, my guess is because there is a file or something in use on the existing M drive. Thus you can't disconnect it easily. Maybe poke around Microsoft's website a little to see if this is documented. Also, make sure there isn't a conflict between the time the disconnect command is initiated to when it tries to connect the new path (there is quite a lag when disconnecting some drives).

I'd suggest testing it by mapping a drive as M, then open a file via the network drive and try some network commands to close the connection.

If I were you, I'd have my script first try to disconnect the existing M drive. Then if it didn't successfully diconnect I'd just have a VBS window display telling the user how to manually disconnect that they'd need to log off and back on again in order to have the M drive available.
Not sure if that's an option in your environment or not...


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Can't get mapped drive to disconnec

Can't Get CD drive to work www.computing.net/answers/windows-2000/cant-get-cd-drive-to-work/48387.html

Can't see CD Drives in Win2000 www.computing.net/answers/windows-2000/cant-see-cd-drives-in-win2000/37289.html

Can't get WIndows 2000 to reinstall www.computing.net/answers/windows-2000/cant-get-windows-2000-to-reinstall/56547.html