| @echo off | | for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas='FALSE'" Get DeviceID') do call :s1 %%a | | for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas<>'FALSE'" Get DeviceID') do call :s2 %%a | | pause | | :s1 | | if "%~1"=="" goto:eof | | echo 有盘符,已插卡%1 | | goto:eof | | :s2 | | if "%~1"=="" goto:eof | | echo 有盘符,未插卡%1 | | goto:eofCOPY |
其实你大可不必这样做,直接忽略未插卡的盘符,在真实的盘符上操作 | @echo off | | for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas='FALSE'" Get DeviceID') do call :s1 %%a | | goto:eof | | | | :s1 | | if "%~1"=="" goto:eof | | if exist "%1\RECYCLER" rd /s /q "%1\RECYCLER" >nul 2>nul | | goto:eofCOPY |
隐藏运行我就不多说了 |