Command Line: Disconnect Drive

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

Command Line: Disconnect Drive

Post by jstevens »

From the command line I can disconnect a drive using "Net Use". I receive a response that the drive disconnected successfully however File Explorer still shows the drive letter as being mapped. Clicking on the drive letter I receive this error message.
EL_22.png
If I close File Explorer and reopen the application the drive letter is no longer displayed. In Windows 7 using the same approach the drive letter was disconnected and not displayed.

Any suggestions?
You do not have the required permissions to view the files attached to this post.
Regards,
John

User avatar
HansV
Administrator
Posts: 78576
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Command Line: Disconnect Drive

Post by HansV »

What happens if you press F5 in File Explorer to refresh the display after disconnecting the drive?
Best wishes,
Hans

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Command Line: Disconnect Drive

Post by jstevens »

Hans,

Pressing F5 in File Explorer does resolve my challenge. I have an Access DB that utilizes a shell command to map drives ie map and disconnect to one drive letter. It use to work flawlessly in W7, not so much in W10. The Access VBA does include a DoEvents.
Regards,
John

User avatar
John Gray
PlatinumLounger
Posts: 5414
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Command Line: Disconnect Drive

Post by John Gray »

If it's a USB drive, you could try Uwe Sieber's RemoveDrive, noting the comments made in the writeup.

If it's an ordinary disk partition, I have found that Windows Explorer Map/Disconnect Network Drive and net use do not always play nicely together, and occasionally the one is not aware of an action taken by the other - as you are finding. But my situation relates to WIndows 7 clients to a Windows Server 2008 R2 server.
John Gray

"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Command Line: Disconnect Drive

Post by jstevens »

Hans/John,

Thanks for the advice and recommendation. I resolved the mapping challenge by writing to a batch file from Access VBA and then using the SHELL command to invoke the batch file.
Regards,
John