Tip: Unmap (disconnect) network drive via command line (cmd)

When you have to disconnect your network drives you first need to know which ones of them are connected. You can run into issues (especially Windows 10 users) that your network drives do not appear under your Computer window, but when you try to connect, you will get a message that they are already connected, maybe even with a different username that you tried. 

This leads you into needing to unmap the drives via command line. 

How to list and unmap network drives via command line?

1. Start command prompt as administrator.

Type cmd in your search box and right click the icon, then select “Run as administrator”

run-as-administrator-cmd

 

2. Move to C disk or other location rather than staying in Windows\System32 in command line.

To navigate to C:\ disk Type cd c:\ in the cmd command line 

cd-c-command-line-folders

3. Display the list of current network drives attached

Type net use and hit enter – this will display the network drives.

It is better for deleting if you output the results in a text file where you can copy the paths later. 

Type net use > networkdrives.txt in the command line, then a file named networkdrives.txt will be saved to C disk (go and open it).

 

4. Unmap the drives you want to unmap. 

Unmapping / disconnecting a drive from command line is done via net stop. To stop / disconnect a network drive correctly, use this command

net use \\thepath\toyournetworkfolder /delete

Tip: the path to your network folder, that you have attached as a network drive can be copied and pasted via mouse right click to command line from the txt file we generated in step 3. 

Now you have disconnected the network drive. 

Make sure to check again by typing net use in the command line. If the entry is gone, you have been successful. 

 net-use-delete-mapped-drive-network-command-line

More discussion on the subject:

http://www.pcreview.co.uk/threads/disconnect-network-drive-with-a-net-command-line-command-opposite-of-net-use.2518200/

http://superuser.com/questions/435009/how-to-remove-disconnected-drives-from-windows-explorer 

http://superuser.com/questions/135752/list-mapped-network-drives-from-the-command-line-to-text-file 

 

Post Author: Tom Pai