第二句是为了提权,如果是PE环境下可以删掉
vol是查找的卷标- @echo off & cd /d "%~dp0"
- %1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","REM",,"runas",1)(window.close)&exit
- set "diskNo=-1"
- set "vol=Win10"
- for /l %%i in (0,1,10) do (
- (
- echo select disk %%i
- echo detail disk
- ) | diskpart | findstr /i /C:" %vol% " >nul 2>nul && (
- set "diskNo=%%i"
- goto :next
- )
- )
- :next
- echo %diskNo%
- pause&exit
复制代码
|