[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
step1_1.bat
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /f "tokens=1-9 delims=: " %%a in ('type "diskpart.txt" ^| findstr /n ".*"') do (
  4.     if "%%d" equ "联机" (
  5.         if "%%i" equ "*" (
  6.             set "_%%b %%c=GPT"
  7.         ) else (
  8.             set "_%%b %%c=MBR"
  9.         )
  10.     )
  11.     if "%%b" equ "磁盘" (
  12.         set "DiskNum=%%c"
  13.         set MaxMB=0
  14.         set MaxGB=0
  15.         set DiskLine=%%a
  16.     )
  17.     if "%%d" equ "系统" (
  18.         set "StrDisk=磁盘 !DiskNum!"
  19.         call set strPT=%%_!StrDisk!%%
  20.         call :MaxPartition !DiskLine!
  21.         if !MaxGB! neq 0 (
  22.             set "strPartition=分区!PartitionNumG!"
  23.         ) else if !MaxMB! neq 0 (
  24.             set "strPartition=分区!PartitionNumM!"
  25.         )
  26.         goto :EndStep1_1
  27.     )
  28. )
  29. goto :eof
  30. :MaxPartition
  31. for /f "skip=%1 tokens=1-8" %%a in ('type "diskpart.txt"') do (
  32.     if "%%a" neq "磁盘" (
  33.         if "%%e" equ "MB" (
  34.             if %%d gtr !MaxMB! (
  35.                 set MaxMB=%%d
  36.                 set PartitionNumM=%%b
  37.             )
  38.         ) else if "%%e" equ "GB" (
  39.             if %%d gtr !MaxGB! (
  40.                 set MaxGB=%%d
  41.                 set PartitionNumG=%%b
  42.             )
  43.         )
  44.     ) else (
  45.         goto :eof
  46.     )
  47. )
  48. goto :eof
  49. :EndStep1_1
  50. set StrResult1_1=!StrDisk: =!!strPartition!,!strPT!,最大!strPartition!
  51. >"0.txt" echo !StrResult1_1!
复制代码

TOP

回复 2# happy886rr


    把你的代码发出来给大家学习一下吧

TOP

返回列表