|
@echo off
attrib -h -r "%~dp0%winxp.vhd"
:ListDisk
echo --------------------------------------------------------------------
echo 请在Win7PE下运行该文件
echo --------------------------------------------------------------------
echo 下面开始,您需要做1道非常简单的数学题,题目本身非常简单
echo 简单到连幼儿园的小朋友都会做
echo 不过这道题却非常重要,如果做错了...
echo 嘿嘿,您要哭鼻子了...可别找我诉苦哦...
echo So,Be Carefull!
echo 打起精神,专心做题啦!
echo --------------------------------------------------------------------
pause
:Cal
cls
for /f "tokens=2" %%i in ('echo list disk^|diskpart^|find "磁盘"') do set disk0=%%i
set /P disk0=请计算 %disk0%+1=几? :
set /A disk1=%disk0%+1
set /A disk2=%disk1%+1
cls
echo ********************************************************************
echo 您的电脑已经安装了 %disk0% 块物理磁盘
echo --------------------------------------------------------------------
echo 原 winxp.vhd文件 将被挂载成第%disk1%块虚拟磁盘
echo 新 press.vhd文件 将被挂载成第%disk2%块虚拟磁盘
echo --------------------------------------------------------------------
echo 将通过下面的Ghost命令达到压缩VHD文件的效果:
echo ghost32 -clone,mode=copy,src=%disk1%,dst=%disk2% -sure
echo ********************************************************************
echo.
SET /P IsOK=上面的信息是否准确?(必须输入字母y并回车方可继续)
if /I not "%IsOK%"=="y" goto Cal
cls
echo Create Vdisk FILE="%~dp0%press.vhd" MAXIMUM=6164 TYPE=EXPANDABLE > createhd.txt
diskpart /s createhd.txt
echo.
pause
echo Select Vdisk FILE="%~dp0%winxp.vhd" > selecthd.txt
echo Attach Vdisk >> selecthd.txt
echo Select Vdisk FILE="%~dp0%press.vhd" >> selecthd.txt
echo Attach Vdisk >> selecthd.txt
echo list disk >> selecthd.txt
echo.
echo.
diskpart /s selecthd.txt
echo --------------------------------------------------------------------
echo 下面就要开始通过Ghost硬盘对拷的功能压缩WinXP.VHD文件了
echo 请耐心等待Ghost操作,同时请不要关闭本窗口!
echo --------------------------------------------------------------------
echo.
pause
Y:\tools\ghost\ghost32 -clone,mode=copy,src=%disk1%,dst=%disk2% -sure
::Ghost对拷结束后就分离VHD文件
echo Select Vdisk FILE="%~dp0%winxp.vhd" > unmounthd.txt
echo DETACH Vdisk >>unmounthd.txt
echo Select Vdisk FILE="%~dp0%press.vhd" >> unmounthd.txt
echo DETACH Vdisk >>unmounthd.txt
diskpart /s unmounthd.txt
cls
echo --------------------------------------------------------------------
echo 最后再挂载和分离一下VHD文件
echo --------------------------------------------------------------------
echo 疑惑不解:不知何故,用GHOST对拷后,如果再挂载和分离一下,
echo VHD文件还会变小一些。
echo 这种怪现象我是通过反复对拷一个已经无法再压缩的
echo VHD文件时偶然发现的,为了最大限度的减少VHD体积
echo 就只好反复分离和挂载一下VHD文件了......
echo --------------------------------------------------------------------
pause
:delTemp
del winxp.vhd
ren press.vhd winxp.vhd
cls
echo 下面是二次挂载VHD文件...
echo Select Vdisk FILE="%~dp0%winxp.vhd" > selecthd.txt
echo Attach Vdisk >> selecthd.txt
diskpart /s selecthd.txt
pause
cls
echo 下面是二次分离VHD文件...
echo Select Vdisk FILE="%~dp0%winxp.vhd" > unmounthd.txt
echo DETACH Vdisk >>unmounthd.txt
diskpart /s unmounthd.txt
del *.txt
echo --------------------------------------------------------------------
echo WinXP.VHD压缩完成!
echo --------------------------------------------------------------------
pause |
|