@echo off
goto main
:isremote
setlocal
set _isremote=0
if "%~d1"=="\\" (set _isremote=1) else (
(>nul 2>&1 net use "%~d1") && set _isremote=1
)
endlocal&set isremote=%_isremote%&goto :EOF
:test
call :isremote "%~1"
echo %isremote% == %~1
@goto :EOF
:main
call :test c:
call :test c:\
call :test c:\windows
call :test \\foo
call :test \\foo\
call :test \\foo\bar
call :test \\foo\bar\baz
call :test z:
call :test z:\
call :test z:\temp
В моей системе, где z: подключенный диск, я получаю:
0 == c:
0 == c:\
0 == c:\windows
1 == \\foo
1 == \\foo\
1 == \\foo\bar
1 == \\foo\bar\baz
1 == z:
1 == z:\
1 == z:\temp
Примечание.