|
编写的目的主要是为了方便在安装版的Windows7中实现自动分区,代码如下:
@echo off
title Windows7系统分区助手 V1.0 By fjwSoft
cls
echo ╔═════════════════════════════╗
echo ║欢迎使用Windows7分区向导,本向导将帮您自动完成分区工作... ║
echo ║本程序适用于Windows7PE、Windows7安装版。程序作者:fjwsoft ║
echo ╚═════════════════════════════╝
echo.
echo 警告:请正确选择您要分区的磁盘的容量序号,否则有可能分区失败!!
echo ===============================================================
echo.
set parNum=
set /p parNum=请选择本机硬盘容量(1代表分500G;2代表750G,3代表1T,0代表退出)[1,2,3,0]:
if /i "%parNum%"=="1" goto 500g
if /i "%parNum%"=="2" goto 750g
if /i "%parNum%"=="3" goto 1t
if /i "%parNum%"=="0" goto exitser
:exitser
exit
:500g
set PriSize=51200
set LogiSize=141312
goto begin
:750g
set PriSize=61440
set LogiSize=217088
goto begin
:1t
set PriSize=61440
set LogiSize=891904
:begin
echo =======================
echo 正在清除分区,请稍后...
echo =======================
echo select disk 0 > clean.txt
echo clean >> clean.txt
echo exit >> clean.txt
@start /min /wait diskpart /s clean.txt
echo.
echo 恭喜,清除分区成功!
echo ===================
echo.
echo 正在创建主分区......
echo ====================
echo select disk 0 > primary.txt
echo create partition primary size=%PriSize% >> primary.txt
echo format quick >> primary.txt
echo active >> primary.txt
echo exit >> primary.txt
@start /min /wait diskpart /s primary.txt
echo 恭喜,创建主分区成功!
echo =====================
echo.
echo 正在创建扩展分区......
echo ======================
echo select disk 0 > extended.txt
echo create partition extended >> extended.txt
echo exit >> extended.txt
@start /min /wait diskpart /s extended.txt
echo 恭喜,创建扩展分区成功!
echo =======================
echo.
echo 正在创建逻辑分区1......
echo =======================
echo select disk 0 > logical1.txt
echo create partition logical size=%LogiSize% >> logical1.txt
echo exit >> logical1.txt
@start /min /wait diskpart /s logical1.txt
echo 恭喜,创建逻辑分区1成功!
echo ========================
echo.
echo 正在创建逻辑分区2......
echo =======================
echo select disk 0 > logical2.txt
echo create partition logical size=%LogiSize% >> logical2.txt
echo exit >> logical2.txt
@start /min /wait diskpart /s logical2.txt
echo 恭喜,创建逻辑分区2成功!
echo ========================
echo.
echo 正在创建逻辑分区3......
echo =======================
echo select disk 0 > logical3.txt
echo create partition logical >> logical3.txt
echo exit >> logical3.txt
@start /min /wait diskpart /s logical3.txt
echo 恭喜,创建逻辑分区3成功!
echo ========================
echo.
echo 恭喜,全部分区创建成功,点击“安装 Windows”界面中的“刷新”按钮即可看到划分好的分区。按任意键退出......
pause>nul
exit
将上面的代码复制到bat文件即可,由于个人水平有限,代码中难免有冗余,望朋友们给予指正。谢谢!
[ 本帖最后由 2012fjwsoft 于 2012-5-12 08:56 编辑 ] |
|