纯DOS自动整数分区
的有关信息介绍如下:本文交流学习如何在系统纯DOS下引导自动整数分区,从而达到自动快速安装系统的需要。
用Ultra ISO解压Gdisk.img文件,查看运行文件,独离侵AUTOEXEC.bat,知道其转向gghost文件夹里面的GD.bat文件
修改GD.bat文件,按照自己的要求,按照以下思路进行修改:加载驱动--用Gdisk.exe获取电脑所有硬盘信息--判断是否存在硬盘--多个硬盘提示选择--判断当前选择硬盘是否已经分区(已经分区则出于安全考虑自动退出)--判断当前选择硬盘容量大小--引用合适当前硬盘容量大小的配置--启用Gdisk按照配置进行整数分区操作--完成整数分区--重启到菜单
完成自动分区
需要用到的Gd.bat 代码如下,纯DOS环境中:
==============图片中附带解释============
@echooff
REMBY-XIAO32014.07.30
tw/np/nm/nw>nul
:BEGIN
wbatpal!cls
echo.
echoGdisk一键分区硬盘扫描...
echo.
gotoreset
:reset
ifexistdiskshcn.txtdeldiskshcn.txt>nul
setdisk=1
setdisknumber=
setlastd=
setbackhave=1
gotogdstart
:gdstart
Rem获得所有硬盘信息
gdisk>dn.txt
Rem获得硬盘是否只有一个
gawk'$1~//{lastd=$1}END{printlastd}'dn.txt|nsetlastd=$1
if%lastd%.==.gotonodiskhave
if%lastd%.==1.gotodiskhave1
ifnot%lastd%.==1.gotodiskhaven
:diskhaven
echo.
wbatpal!cls
echo.
echoGdisk一键分区硬盘有多个...
setdisknumber=9
echoGdisk一键分区进入循环寻找...
gotoshowloop
:diskhave1
echo.
wbatpal!cls
echo.
echoGdisk一键分区硬盘只有1个...
setdisknumber=1
echoGdisk一键分区进入显示当前盘信息...
gotohd1
:showloop
wbatpal!cls
echo.
echoGdisk一键分区硬盘扫描加载...
Rem显示细节生成选择界面文件diskshcn.txt内容
echo:cn_1"Gdisk一键分区硬盘统计">diskshcn.txt
echo.>>diskshcn.txt
echo选择硬盘>>diskshcn.txt
setline=1
echo.>>diskshcn.txt
echo[&%line%第%line%硬盘]>>diskshcn.txt
gotoloopstart
:loopstart
if%line%.==%lastd%.gotoloopend
stringsline=add%line%,1
echo.>>diskshcn.txt
echo[&%line%第%line%硬盘]>>diskshcn.txt
gotoloopstart
:loopend
wbatpal!cls
echo.
echoGdisk一键分区硬盘扫描完成...
gotoshowall
:showall
wbatpal!cls
echo.
echoGdisk一键分区硬盘扫描中文数据...
Rem显示细节
Echo.>>diskshcn.txt
Echo.>>diskshcn.txt
echo#?秒后自动选择第一个盘>>diskshcn.txt
echo本机所有可用硬盘列表:>>diskshcn.txt
Echo.>>diskshcn.txt
echo硬盘分区数型号容量(GB)>>diskshcn.txt
gawk'$1~//{print$1,$2,$7,$6>>吐泛"diskshcn.txt"}'dn.txt
echo::>>diskshcn.txt
gotoshowlist
:showlist
wbatpal!cls
Rem显示选择框
callw.batbox5@diskshcn.txt:cn_1#1,10
iferrorlevel100gotohd1
if"%?%"=="联离9"gotohd9
if"%?%"=="8"gotohd8
if"%?%"=="7"gotohd7
if"%?%"=="6"gotohd6
if"%?%"=="5"gotohd5
if"%?%"=="4"gotohd4
if"%?%"=="3"gotohd3
if"%?%"=="2"gotohd2
if"%?%"=="1"gotohd1
gotoexit
:hd1
setdisk=1
gawk'$1~/1/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
:hd2
setdisk=2
gawk'$1~/2/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
:hd3
setdisk=3
gawk'$1~/3/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
:hd4
setdisk=4
gawk'$1~/4/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
:hd5
setdisk=5
gawk'$1~/5/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
:hd6
setdisk=6
gawk'$1~/6/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
:hd7
setdisk=7
gawk'$1~/7/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
:hd8
setdisk=8
gawk'$1~/8/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
:hd9
setdisk=9
gawk'$1~/9/{print$1,$2,$6>"diskbig.txt"}'dn.txt
gotonext2
Rem共有多少个硬盘《《《《《《
:next2
wbatpal!cls
echo.
echoGdisk一键分区硬盘扫描判断当前磁盘是否已经分区...
gawk'$1~//{diskscnc=$2}END{printdiskscnc}'diskbig.txt|nsetdiskscnc=$1
echo.
echo分区数:%diskscnc%
pause
Rem当前选择磁盘是否已经分区
ifnot%diskscnc%.==0.gotoexithave
gotonext3
:exithave
setbackcn=4
if%backhave%.==%backcn%.gotoexitask
stringsbackhave=add%backhave%,1
echo:exithave"Gdisk一键分区硬盘提醒">exithave.txt
echo.>>exithave.txt
echo当前硬盘已经存在分区,自动退出分区功能,>>exithave.txt
echo.>>exithave.txt
echo#?秒后重新返回硬盘选择界面.>>exithave.txt
echo.>>exithave.txt
echo[&EIDT][重选(&R)][重启(&S)][&DOSMAX][菜单(&M)]>>exithave.txt
echo::>>exithave.txt
wbatpal!cls
callw.batbox@exithave.txt:exithave#2,2
iferrorlevel100gotoexit
if"%?%"=="5"gotoEZBOOT
if"%?%"=="4"exit
if"%?%"=="3"rb
if"%?%"=="2"gotoshowlist
if"%?%"=="1"gotoedit
gotoexit
:next3
wbatpal!cls
gawk'$1~//{disksbig=$3}END{printdisksbig}'diskbig.txt|nsetdisksbig=$1
echo.
echo分区大小数:%disksbig%
pause
rem判断磁盘大小,确定分区自动方案
setgetbig=409703
ECHO判断磁盘400.01-2000G
PAUSE
echo%getbig%%disksbig%|gawk'{sz=($2-$1)}END{printsz}'>disktemp.ini
nset/S.ifbiger=$1 stringsifbig=left%ifbiger%,1 ifnot%ifbig%.==-.gotoTO400G setgetbig=204906 echo判断磁盘200-400G pause echo%getbig%%disksbig%|gawk'{sz=($2-$1)}END{printsz}'>disktemp.ini nset/S.ifbiger=$1 stringsifbig=left%ifbiger%,1 ifnot%ifbig%.==-.gotoTO200G setgetbig=79878 echo判断磁盘80-200G pause echo%getbig%%disksbig%|gawk'{sz=($2-$1)}END{printsz}'>disktemp.ini REM尝试运行,disktemp.ini内容-79878,跳转到T020G nset/S.ifbiger=$1 stringsifbig=left%ifbiger%,1 ifnot%ifbig%.==-.gotoTO80G gotoTO20G setgetbig=7892 echo判断磁盘10-80G pause echo%getbig%%disksbig%|gawk'{sz=($2-$1)}END{printsz}'>disktemp.ini nset/S.ifbiger=$1 stringsifbig=left%ifbiger%,1 ifnot%ifbig%.==-.gotoTO20G gotoTO10G :TO10G wbatpal!cls echo. echoGdisk一键提醒,你的硬盘不够进行分区... echo. echoGdisk一键分区硬盘1G-10G分区... PAUSE gotoshowlist :TO20G wbatpal!cls echo. echo判断磁盘10-80G2 pause echoGdisk一键分区硬盘10G-80G分区...分为:20GCPIR+20GDPRI+XGLOG... echo. echo#警告:Gdisk执行脚本,不可随意修改!>g_gdisk.ini echo/CRE/PRI/SZ:20482/FOR/Q/NTFS/V:WIN7>>g_gdisk.ini echo/CRE/PRI/SZ:20482/FOR/Q/NTFS/V:D>>g_gdisk.ini echo/CRE/EXT>>g_gdisk.ini echo/CRE/LOG/FOR/Q/NTFS/V:E>>g_gdisk.ini gotonext4 :TO80G wbatpal!cls echo. echo判断磁盘80-200G2 pause echoGdisk一键分区硬盘80G-200G分区...分为:30GCPIR+30GDPRI+XGLOG... echo#警告:Gdisk执行脚本,不可随意修改!>g_gdisk.ini echo/CRE/PRI/SZ:30726/FOR/Q/NTFS/V:WIN7>>g_gdisk.ini echo/CRE/PRI/SZ:30726/FOR/Q/NTFS/V:D>>g_gdisk.ini echo/CRE/EXT>>g_gdisk.ini echo/CRE/LOG/FOR/Q/NTFS/V:E>>g_gdisk.ini gotonext4 :TO200G wbatpal!cls echo. echo判断磁盘200-400G2 pause echoGdisk一键分区硬盘200G-400G分区...分为:50GCPIR+50GDPRI+100GELOGPRI+XGLOG... echo#警告:Gdisk执行脚本,不可随意修改!>g_gdisk.ini echo/CRE/PRI/SZ:51208/FOR/Q/NTFS/V:WIN7>>g_gdisk.ini echo/CRE/PRI/SZ:51208/FOR/Q/NTFS/V:D>>g_gdisk.ini echo/CRE/EXT>>g_gdisk.ini echo/CRE/LOG/SZ:102408/FOR/Q/NTFS/V:E>>g_gdisk.ini echo/CRE/LOG/FOR/Q/NTFS/V:F>>g_gdisk.ini gotonext4 :TO400G wbatpal!cls echo. ECHO判断磁盘400.01-2000G2 PAUSE echoGdisk一键分区硬盘400G-8000G分区...分为:100GCPIR+100GDPRI+100GELOGPRI+XGLOG... echo#警告:Gdisk执行脚本,不可随意修改!>g_gdisk.ini echo/CRE/PRI/SZ:102408/FOR/Q/NTFS/V:WIN7>>g_gdisk.ini echo/CRE/PRI/SZ:102408/FOR/Q/NTFS/V:D>>g_gdisk.ini echo/CRE/EXT>>g_gdisk.ini echo/CRE/LOG/SZ:102408/FOR/Q/NTFS/V:E>>g_gdisk.ini echo/CRE/LOG/FOR/Q/NTFS/V:F>>g_gdisk.ini gotonext4 :next4 echo/ACT/P:1>>g_gdisk.ini echo/MBR/z>>g_gdisk.ini echogdisk%disk%/batch:g_gdisk.ini/y>run.bat echo:lastok"Gdisk一键分区分区前确认">lastok.txt echo#?秒后自动确认>>lastok.txt echo[取消(&S)][确认(&R)][菜单(&M)]>>lastok.txt echo::>>lastok.txt cls callw.battext15,7(+whiteonblack)@g_gdisk.ini callw.batbox@lastok.txt:lastok#2,1 iferrorlevel100gotoexit if"%?%"=="3"gotoEZBOOT if"%?%"=="2"gotorunok if"%?%"=="1"gotoexitask gotoexit :runok cls tw/q>nul callrun tw/np/nm/nw>nul cls echo:exitrb"Gdisk一键分区重启/关机提醒">exitrb.txt echo.>>exitrb.txt echoGdisk已经完成当前硬盘分区>>exitrb.txt echo.>>exitrb.txt echo#?秒后重启/关机>>exitrb.txt echo.>>exitrb.txt echo[&MS-DOS][重启(&R)][关机(&S)][菜单(&M)]>>exitrb.txt echo.>>exitrb.txt echo::>>exitrb.txt callw.batbox@exitrb.txt:exitrb#2,2 iferrorlevel100gotoexit if"%?%"=="4"gotoEZBOOT if"%?%"=="3"off if"%?%"=="2"rb if"%?%"=="1"gotoexit gotoexit :nodiskhave ifnotexistdn.txtgotoramd typedn.txt|find/i"disks">nul iferrorlevel1gotoramd gotonohd :ramd setredo=1 xmsdsk10240/y>nul findramd>nul xcopy*.*%ramdrive%\/s/y>nul path=%ramdrive%\;a:\;a:\gghost %ramdrive%\ gd :nohd cls echo. echo:nohd"Gdisk一键分区无硬盘提醒">nohd.txt echo.>>nohd.txt echoGdisk无法找到硬盘>>nohd.txt echo.>>nohd.txt echo#?秒后自动关机>>nohd.txt echo.>>nohd.txt echo[&DOSMAX][关机(&R)][重启(&S)][菜单(&M)]>>nohd.txt echo::>>nohd.txt wbatpal!cls callw.batbox@nohd.txt:nohd#2,2 iferrorlevel100gotoexit if"%?%"=="4"gotoEZBOOT if"%?%"=="3"rb if"%?%"=="2"off if"%?%"=="1"gotoexit rb :edit cls edit :exitask echo:exitall"Gdisk一键分区退出提醒">exitall.txt echo.>>exitall.txt echoGdisk正在退出>>exitall.txt echo.>>exitall.txt echo#?秒后自动关机>>exitall.txt echo.>>exitall.txt echo[&DOSMAX][关机(&R)][重启(&S)][菜单(&M)]>>exitall.txt echo::>>exitall.txt wbatpal!cls callw.batbox@exitall.txt:exitall#2,3 iferrorlevel100gotoexit if"%?%"=="4"gotoEZBOOT if"%?%"=="3"rb if"%?%"=="2"off if"%?%"=="1"gotoexit gotoexit :EZBOOT cls ezboot.com EXIT :exit cls EXIT ====================== 用EasyBoot制作带引导Gdisk.img的启动盘,放在VMware虚拟机里面尝试运行,查看运行结果 虚拟机中运行结果,分区结果完美而且是整数的。