回复 45# 5i365
提示的中文显示多加个判断
变量的后面习惯性的多打了个空格- @echo off
- chcp 437
- echo list vol|diskpart|findstr /i "volume.*no" &&set f=1||chcp 936
- if not defined f start mshta vbscript:msgbox("没找到卷标为no的分区",0,"%提醒%")(window.close)&&exit
- if exist dsk.txt del dsk.txt
- for /f "tokens=2,3 delims= " %%a in ('echo list vol^|diskpart^|findstr /i "volume.*no"') do (
- if exist %%b:\windows\system32 (
- for /f "tokens=2 delims=* " %%c in ('^(echo sel vol %%a ^&echo list disk^)^|diskpart^|findstr "*"') do set disk=%%c&BOOTICE /DEVICE=%%c /mbr /backup /sectors=1 /quiet /file=MBR_Bak
- (echo select volume %%a
- echo delete volume)|diskpart
- )
- )
-
- for /f "tokens=2 delims= " %%c in ('^(echo select disk %disk% ^&echo list part^)^|diskpart^|findstr /i "System Reserved Recovery"') do (
- if not "%%c"=="" (
- (echo sel disk %disk%
- echo sel part %%c
- echo del part override)>>dsk.txt
- )
- )
-
- for /f "tokens=2 delims= " %%a in ('^(echo select disk %disk% ^&echo detail disk^)^|diskpart^|findstr /i "volume.*no"') do (
- if not "%%a"=="" (
- (echo select volume %%a
- echo delete volume)>>dsk.txt
- )
- )
- echo;exit>>dsk.txt
- if exist dsk.txt diskpart /s dsk.txt
- del dsk.txt
- for /f "tokens=3 delims= " %%c in ('echo list vol^|diskpart^|findstr /i "volume.*data"') do set data_pf=%%c
- set no_yph=%disk%
- pause
复制代码
|