Consequently, I wrote this little batch file that will determine where the package is running from and will return (in the variable _uncshare) the UNC path of the drive. This works whether the batch file is run from a mapped drive or a UNC path. If the batch file is running from a local drive, it just returns the drive letter.
set _drive=
set _uncshare=
set _drive=%~d0
if "%_drive%"=="\\" (
for /f "tokens=1,2 delims=\" %%a in ("%~dp0") do set _uncshare=\\%%a\%%b
) ELSE (
for /f "tokens=2,3" %%a in ('net use') do if /i "%%a"=="%_drive%" set _uncshare=%%b
)
:: Below handles case where we are not running off a mapped drive -
:: just return drive
if NOT DEFINED _uncshare set _uncshare=%_drive%
echo %_uncshare%
0 comments:
Post a Comment