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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RemoveNetworkDrive fails to remove the share name

Status
Not open for further replies.

techuser123

Technical User
Sep 2, 2008
3
US
Attached is an excerpt of the VBA code I use in Access to remap a drive. When the drive is not in use, it gets mapped without a problem. When it is in use, the RemoveNetworkDrive works (no error), but the share name that I see in explorer doesn't change. If I step through the code, I see the mapped drive get disconnected, and the new share get created with the correct name. What am I doing wrong? What is different from when I run the code as opposed to stepping through it?

Set nw = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.DriveExists("Y:") Then
nw.RemoveNetworkDrive "Y:", True, True
Sleep 300
End If
nw.MapNetworkDrive "Y:", sShare, False
Set fso = Nothing
Set nw = Nothing


I noticed other threads on here with similar problems, but never found an answer to what I am experiencing.

Thanks in advance for any help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top