|
本帖最后由 dos时代菜鸟 于 2024-5-20 19:02 编辑
唉,给你个现成的算了。 找出 usb 盘 让你自己选择,然后直接分区。
- @echo off
- SETLOCAL ENABLEDELAYEDEXPANSION
- echo 正在获取 usb_disk 信息 ......
- set "diskpart_cmd=echo rescan ^& echo list disk"
- set disks=
- for /f "delims=" %%x in ('^(!diskpart_cmd!^)^|diskpart') do (
- for /f "tokens=2" %%c in ("%%x") do (
- if defined disks (
- set disk%%c=%%x
- set "disks=!disks!,%%c"
- )
- if "%%c"=="-------------" set "disks=,"
- )
- )
- set diskpart_cmd=echo rem
- for %%c in (!disks!) do (
- set "diskpart_cmd=!diskpart_cmd! ^& echo select disk %%c ^& echo detail disk"
- )
- set usb_s=
- set usb_n=0
- for /f "tokens=1,2,3 delims=: " %%c in ('^(!diskpart_cmd!^)^|diskpart') do (
- if "%%c%%e"=="磁盘现在是所选磁盘。" set "diskx=%%d"
- if "%%c"=="类型" (
- if /I "%%d"=="USB" (
- set /a usb_n+=1
- SET "usb_s=!usb_s! !diskx!"
- )
- set diskx=
- )
- )
- if !usb_n! equ 0 (
- echo 没有U盘...
- goto :end1
- )
- :select1
- cls
- echo.
- echo 部署 usb_disk ...
- echo.
- echo USB盘列表:
- echo ---------------------------------------------------------------------
- for %%c in (!usb_s!) do (echo !disk%%c!)
- echo ---------------------------------------------------------------------
- if !usb_n! geq 2 (
- set /p disk_U=请选择一个U盘(!usb_s! , X退出):
- if /i "!disk_U!"=="X" goto :end1
- set find1=0
- for %%c in (!usb_s!) do (
- if !disk_U! equ %%c set find1=1
- )
- if !find1! equ 0 (
- echo 选择错误,请按任意键重新来过....
- pause>nul
- goto :select1
- )
- )else (
- set /a disk_u=!usb_s!
- SET /P X=按任意键开始对唯一的 U 盘进行部署(X退出)....
- if /i "!x!"=="x" goto :end1
- )
- echo.
- echo.
- echo 对 USB_disk #!disk_U! 进行分区部署:
- call :fdisk1 !disk_U!
- :end1
- pause
- goto :eof
- :fdisk1
- echo 请稍等......
- (
- echo select disk %1
- echo clean
- echo convert gpt
- echo create partition efi size=100
- echo format quick fs=fat32 label="System"
- echo create partition msr size=128
- echo create partition primary size=300
- echo format quick fs=ntfs label="Windows RE tools"
- echo assign letter="T"
- echo create partition primary
- echo format quick fs=ntfs label="Windows"
- echo assign letter="W"
- )|diskpart >nul 2>nul
- echo 完毕...
- exit /b
复制代码
|
|