本帖最后由 idwma 于 2021-8-8 15:03 编辑
再改一下加个判断
还是套娃嘛一层不行就两层...- @echo off&setlocal enabledelayedexpansion
- chcp 437
- echo list vol|diskpart|findstr /i "volume.*no" &&set f=1
- if not defined f start mshta vbscript:msgbox("没找到卷标为no的分区",0,"%提醒%")(window.close)&&exit
- for /f "tokens=2,3 delims= " %%a in ('echo list vol^|diskpart^|findstr /i "volume.*no"') do (
- if exist %%b:\windows\system32 (
- (echo select volume %%a
- echo delete volume)|diskpart
- call :re
- for /f "tokens=2 delims=* " %%c in ('^(echo sel vol %%a ^&echo list disk^)^|diskpart^|findstr "*"') do set disk=%%c
- )
- )
- :ll
- for /f "tokens=2 delims= " %%a in ('echo list vol^|diskpart^|findstr /i "volume.*no"') do (
- for /f "tokens=2 delims=* " %%b in ('^(echo sel vol %%a ^&echo list disk^)^|diskpart^|findstr "*"') do (
- if "!disk!"=="%%b" (
- (echo select volume %%a
- echo delete volume)|diskpart
- goto :ll
- )
- )
- )
- pause
- goto :eof
-
- :re
- for /f "tokens=2 delims=* " %%c in ('^(echo sel vol %%a ^&echo list part^)^|diskpart^|findstr "System Reserved Recovery"') do (
- if not "%%c"=="" (
- (echo select volume %%a
- echo sel part %%c
- echo del part override)|diskpart
- goto :re
- )
- )
复制代码
|