conan2095 当前离线
列兵
@echo off for /f "tokens=2,4 delims= " %%i in ('"(echo list disk)|diskpart|findstr /i "mb""') do ( if %%j equ 101 ( (echo select volume=f echo delete volume )>>1.txt )else (echo exit)>>1.txt ) diskpart /s 1.txt复制代码
TOP
terse 当前离线
中将
@echo off set "f=" for /f "tokens=4,5" %%a in ('echo list disk ^|diskpart ^|findstr /r /c:"磁盘 *[0-9] "') do ( if /i "%%a%%b" == "101MB" set f=true ) (if defined f ( echo select volume=f echo delete volume ) else echo exit)>1.txt pause复制代码
czjt1234 当前离线
少校
[code]@echo off >1.txt echo exit for /f %%a in ('"echo list disk |diskpart|findstr /Irc:"101 *MB ""') do ( (echo select volume=f&echo delete volume)>1.txt ) rem diskpart /s 1.txt pause复制代码
yakeyun 当前离线
少尉
@echo off & setlocal enabledelayedexpansion Title 硬盘操作中,请稍等... cd /d "%~dp0" for /f "tokens=2" %%a in ('echo list disk ^| diskpart ^|find/i "101" ^| find /i "MB"') do set px=%%a for /f "tokens=3" %%a in ('echo list volume ^| diskpart ^|find/i "101" ^| find /i "MB"') do set pf=%%a if defined px ( if "%pf%"=="F" ( echo list disk >scriptname.txt echo select disk %px% >>scriptname.txt echo clean >>scriptname.txt diskpart /s "scriptname.txt" )) if exist scriptname.txt (del scriptname.txt) exit复制代码