Created
May 22, 2019 06:35
-
-
Save rwv/0ecdeba9e2abc51878f297dd834c2836 to your computer and use it in GitHub Desktop.
Mount UNC path to an available drive and get drive letter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: mount unc_path to an available drive and get the drive letter | |
set unc_path=\\ShareHost\ShareFolder | |
echo unc_path:%unc_path% | |
net use * %unc_path% | |
echo mount %unc_path% to available drive | |
for /f "tokens=2,3" %%i in ('net use') do if '%%j=='%unc_path% set drive_letter=%%i | |
echo mount to %drive_letter% | |
%drive_letter% | |
echo switch to working directory %drive_letter% | |
net use %drive_letter% /delete /y | |
echo unmount %drive_letter% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment