- @Echo Off&Color 0e
- cd/d %~dp0
- call:Diskpart_List_Disk
- pause
- goto:eof
- :Diskpart_List_Disk
- Reg.exe Query "HKU\S-1-5-19" >nul 2>nul||exit
- if not %ErrorLevel% equ 0 exit
- set "#Grant_Administrators_F$=%SystemRoot%\System32\zh-CN\Diskpart.exe.mui"
- If Exist "%#Grant_Administrators_F$%" >nul 2>nul Takeown.exe /f "%#Grant_Administrators_F$%"
- If Exist "%#Grant_Administrators_F$%" >nul 2>nul Icacls.exe "%#Grant_Administrators_F$%" /Grant Administrators:f")
- If Exist "%#Grant_Administrators_F$%" >nul 2>nul ren "%#Grant_Administrators_F$%" "Diskpart.exe.mui.bak"
- >nul 2>nul set #Diskpart_Volume$
- if %ErrorLevel% Geq 2 for /f "delims==" %%i in ('"set #Diskpart_Volume$"')do set "%%i="
- for /f "skip=8 eol=D tokens=* delims=" %%i in ('"(echo,List Disk)|Diskpart.exe"')do for /f "tokens=1,2,3,4,5,6,7,8 delims= " %%s in ("%%i")do for /f "skip=27 eol=D tokens=1,2,3,* delims= " %%i in ('"(echo,select disk %%t&echo,DetAil disk)|Diskpart.exe"')do if /i "%%t%%z"=="%%t" (set "#Diskpart_Volume_%%k$=%%k;%%t;MBR")else (set "#Diskpart_Volume_%%k$=%%k;%%t;GPT")
- for /f "skip=8 eol=D tokens=* delims=" %%i in ('"(echo,List Disk)|Diskpart.exe"')do for /f "tokens=1,2,3,4,5,6,7,8 delims= " %%s in ("%%i")do for /f "skip=8 eol=D tokens=* delims=" %%i in ('"(echo,select disk %%t&echo,DetAil disk)|Diskpart.exe"')do if not defined #Diskpart_Disk_%%t$ set "#Diskpart_Disk_%%t$=%%t;%%i"
- set "#Diskpart_Volume_
- set "#Diskpart_Disk_
- If Exist "%#Grant_Administrators_F$%.bak" >nul 2>nul ren "%SystemRoot%\System32\zh-CN\Diskpart.exe.mui.bak" "Diskpart.exe.mui"
- set "#Error_Diskpart_Volume$="&&set "#Error_Diskpart_Disk$="
- >nul 2>nul set #Diskpart_Volume_
- if %ErrorLevel% equ 0 set "#Error_Diskpart_Volume$=1"
- >nul 2>nul set #Diskpart_Disk_
- if %ErrorLevel% equ 0 set "#Error_Diskpart_Disk$=1"
- goto:eof
复制代码
|