进度更新,卡到变量嵌套更新了- @echo off
- ::自动请求以管理员权限运行
- if /i "%systemdrive%"=="C:" reg query HKU\S-1-5-20>nul 2>nul || echo;CreateObject^("Shell.Application"^).ShellExecute "%~f0", "%*", "", "runas", 1 > "%temp%\getadmin.vbs" && cscript //b "%temp%\getadmin.vbs" && exit /b & del "%temp%\getadmin.vbs" /f /q>nul
-
- ::SetLocal EnableDelayedExpansion
- ::设置批处理所在目录
- set DIR_CUR=%~dp0
- cd %DIR_CUR%
-
- color 02
- :: 磁盘总数,从0开始
- for /f "delims=" %%i in ('echo list disk^|diskpart^|findstr /i "联机"') do (set /a dn+=1)
- set /a DSK_NO=%dn%-1
-
-
- :: 生成磁盘信息
- if exist dp_t.txt del dp_t.txt
- for /l %%i in (0,1,!DSK_NO!) do (
- (echo sel disk %%i & echo detail disk & echo list part)|diskpart>>dp_t.txt
- )
-
- ::解析内容,生成硬盘分区文件 [序号,磁盘号,分区号,大小,文件系统, 盘符,标签]
- for /f "delims=" %%j in (dp_t.txt) do (
- set "ol=%%j"
- ::行号
- set /a l+=1
- ::echo 第!l!行: !ol:~38,4!
- if "!ol:~0,5!"=="在计算机上" (set /a n=!l!+2 & set /a t=!l!+4 & set /a p=!l!+6)
- if !l!==!n! (set nn=!ol:~3,1!)
- if !l!==!t! (set tt=!ol!)
- if !l!==!p! (set pp=!ol:~7! & (echo ***** !nn! !tt! !pp! *****))
- if "!ol:~38,4!"=="磁盘分区" (
- set ttt=!ol:~50,7!
- set "ttt=!ttt: =!"
- (echo 盘符-文件系统-大小 !ol:~14,1! !ol:~31,5! !ol:~50,7!)
- (set lb!ttt!=!ttt!)
- (set PF!ttt!=!ol:~14,1!)
- (set FS!ttt!=!ol:~31,5!)
- (echo xxxxxxxxxxxxxxxxx:lb!ttt!)
- )
- SetLocal EnableDelayedExpansion
- if "!ol:~0,7!"==" 分区 " (
- set /a b+=1
- set ppp=!ol:~33,7!
- set "ppp=!ppp: =!"
- (echo !b! !nn! 盘符 文件系统 标签 !ol:~10,1! !ol:~15,3! !ppp!)
- echo PPPPPPPPPPPFFFFFFFFFF:lb!ppp!
- if defined lb!ppp! (echo 卡到这里了 lb!ppp! %PF!ppp!% %FS!ppp!%) else (echo 不可更新 lb!ppp!)
- )
- )
-
-
- echo.
- pause
复制代码
|