After we posted the methods to map network drive using cmd commands we come this time with the method to unmap network drive using net use command. Certainly, you need some time to disconnect some of the mapped drives. This is a different method from the standard and easy one using the explore the interface. Mostly used to automate processes on your network environment.
Read here: how to map network drive using cmd commands
Unmap Network Drive Command Line
How to unmap network drive using cmd commands “net use delete”
The following method uses a command prompt (cmd) to remove network drive from the computer.
- Open the command prompt by searching for cmd on windows search. Open with “run as admin” by right click it.
- Copy and paste the below commands
net use T: /delete
Note! Edit the T: on the example above with your network drive
You will receive a confirmation that the mapped network drive has been deleted successfully. Go to the file explorer to check and the mapped drive will be removed. Keep in mind that this command will delete only map drive that uses a letter and not for mappings as an FTP server or web server.
How to remove all mapped network drive on certain computer
What if you will need to delete all the mapped network drive from a certain computer? For this case come in help the “*” string.
So use the below command:
net use * /delete.
This command will ask you for confirmation before removing all the mapped drive and you will need to type “Y” to confirm ore “N” to decline.
You want to include the above task on the command? Yes sure use the below command in order to not prompt for confirmation:
net use * /delete /y
How to delete mapped network drive using Regedit
Another method te delete mapped network drive is the regedit. To do this:
- Open Regedit by searching it on windows search.
- Navigate to the following path – HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2
- On the mapped network drive that you want to delete, right-click, and delete.
- Browser to the next path – Computer\HKEY_CURRENT_USER\Network
- Right-click on the network share that you want to delete and select delete
- Restart the computer
After the restart, the mapped network drive will be removed from the File Explorer.
Batch file to unmap network drive
If you are on-network environment and you will need to remove the mapped network drive to all computers, the following method will come in help. You can schedule this bat file to run on GPO or any other platform used to manage computers. Open notepad and save the below command as remove_map.bat
@echo remove network drive T:/ net use T: /delete. :exit
The following script will delete all mapped network drive without prompt
@echo remove all network drive net use * /delete /y :exit
How to Unmap network drive using Powershell
Instead of Command prompt, you can use also PowerShell. Powershell uses different commands like below:
Remove-PSDrive -Name T
Bonus tip:
Before you execute the delete command you can show the current mapped drive using the below command:
Get-SmbMapping
Conclusion
We try to include all the methods using commands to unmap network drive from the computer. Let’s hope that you find it helpful.