To delete all mapped drives, you can use the following command:
net use * /d /y
If you want a record of what was mapped, or you need the ability to remap the drives later, you can use RemapAll.bat.
NOTE: See tip 3457 » How do I delete all the drives I have mapped with a Subst command?
NOTE: See tip 3491 » How do I extract the 'server' and 'share name' from a drive letter mapped by 'net use'?
NOTE: See tip 4161 » How can I run a script on client computers that requires a mapped drive if they don't have any available drive letters?
The syntax for using RemapAll.bat is:
RemapAll \[FileName\] \[/p\]
where:
FileName | optionally records the mapping and can be used to remap the drive letters. |
/p | is an optional parameter that causes the FileName remapping to be persistent. |
RemapAll.bat contains:
@echo off setlocal set file=^>nul set per=/PERSISTENT:NO if \{%1\}\{\} goto delete set dp=%~dp1 if not exist %dp% goto syntax set file=%1 if \{%2\}
\{\} goto delete if /i "%2" EQU "/p" set per=/PERSISTENT:YES&goto delete :syntax @echo Syntax: RemapAll \[FileName\] \[/p\] endlocal goto :EOF :delete if "^%file%" EQU "^>nul" goto doit if exist %file% del /q %file% set file=^>^>%file% :doit for /f "Skip=1 Tokens=*" %%i in ('net use * /d /y') do set line="%%i"&call :parse endlocal goto :EOF :parse if not "%line:~2,1%" EQU ":" goto :EOF set drive=%line:~1,2% set Svrshr=%line:~17,99% set svrshr=%svrshr:"=% %per% @echo net use %drive% %svrshr%%file%
0 comments
Hide comments