или перебирать пути из net use
@echo off
net use >netuse.tmp
SET DISK1=OFF
SET DISK2=OFF
SET DISK3=OFF
FOR /F "tokens=*" %%a in ('findstr.exe "\\\\192.168.0.111\\all" netuse.tmp') DO (
SET DISK1=ON
)
FOR /F "tokens=*" %%a in ('findstr.exe "\\\\192.168.0.111\\backup" netuse.tmp') DO (
SET DISK2=ON
)
FOR /F "tokens=*" %%a in ('findstr.exe "\\\\192.168.0.111\\ro" netuse.tmp') DO (
SET DISK3=ON
)
if "%DISK1%" == "OFF" (net use ? \\192.168.0.111\all)
if "%DISK2%" == "OFF" (net use ? \\192.168.0.111\backup)
if "%DISK3%" == "OFF" (net use ? \\192.168.0.111\ro)
без темпового файла:
@echo off
set a=NO
FOR /F %%a in ('net use ^| findstr.exe "\\\\192.168.0.111\\all"') DO (
set a=%%a
)
if "%a%"=="OK" GOTO NEXT2
net use ? \\192.168.0.111\all
:NEXT2
set a=NO
FOR /F %%a in ('net use ^| findstr.exe "\\\\192.168.0.111\\backup"') DO (
set a=%%a
)
if "%a%"=="OK" GOTO NEXT3
net use ? \\192.168.0.111\backup
:NEXT3
set a=NO
FOR /F %%a in ('net use ^| findstr.exe "\\\\192.168.0.111\\ro"') DO (
set a=%%a
)
if "%a%"=="OK" GOTO NEXT4
net use ? \\192.168.0.111\ro
:NEXT4