浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(5)-完结
本帖最后由 lblneva 于 2013-3-26 15:32 编辑浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(5)-完结 By lblneva
本篇接“浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(4)”(下面简称“思路4),主要对笔者一些想法进行探讨。本篇是本系列最后一篇文章。
本系列以往文章地址:
浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(1):https://bbs.pcbeta.com/viewthread-1294200-1-1.html浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(2):https://bbs.pcbeta.com/viewthread-1295081-1-1.html浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(3)-1:https://bbs.pcbeta.com/viewthread-1296693-1-1.html浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(3)-2:https://bbs.pcbeta.com/viewthread-1296699-1-1.html浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(4)-1:https://bbs.pcbeta.com/viewthread-1303359-1-1.html浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(4)-2:https://bbs.pcbeta.com/viewthread-1303379-1-1.html
上篇文章,笔者着重介绍如何使用批处理文件配合员工DIY(Windows XP)部署与卸载基于VHD文件启动的Windows 8。本篇将对计算机是新装Windows 7的员工,DIY部署与卸载基于VHD启动的Windows 8进行探讨。
7.5 对Windows 7操作系统进行基于VHD文件启动Windows 8的部署
要启动基于VHD文件启动的Windows 8。需要满足下列要求:
1. 配置升级启动文件,确保bootmgr启动器文件支持VHD内的Windows 82. 正确配置BCD文件,确保bootmgr可以正确引导VHD内的系统启动
写批处理文件时,还要考虑到员工客户端的操作系统。不同的操作系统,引导不一致。这点可以参考笔者“浅谈基于VHD方式在中小型企业内部署Windows8的一些思路与方法(2)”。本文不再叙述。
制作批处理文件处理引导信息,需注意引导类型。
客户机是Windows 7,基于VHD文件启动的windows8的启动过程:
1. 开机MBR引导启动分区bootmgr(必须使用NT6.0引导信息)2. Bootmgr读取BCD信息获取启动项(bootmgr要支持Windows 8)3. OS启动
要注意的有2点:
1. Windows7的bootmgr不支持Windows 8。故Windows 7下员工自主安装基于VHD文件启动的windows8,重要步骤是升级bootmgr。2. 对新硬盘安装Windows 7的计算机启动文件一般存放于隐藏分区的处理。如下图:
可看到新硬盘安装的Windows 7,默认启动文件存放于没有分配盘符的100M的第一个分区
通过对比,不难发现。使用Windows 7的员工要实现DIY安装基于VHD文件启动的windows8,必须使用批处理完成下列3项内容:
1. 分配启动隐藏分区盘符(如有必要)2. 升级bootmgr启动器文件3. 配置BCD启动项,添加基于VHD文件启动的windows8的启动项
7.5.1新硬盘安装Windows 7隐藏启动分区的盘符分配与卸载
批量启动文件存放于启动分区,故需获取启动分区盘符。有部分计算机启动分区没有盘符,需进行分配盘符。盘符分配与卸载批处理如下:
@echo off
echo select disk 0 >%temp%\assign.txt
echo select partition 1 >>%temp%\assign.txt
echo assign=>>%temp%\assign.txt
echo exit>>%temp%\assign.txt
diskpart /s %temp%\assign.txt
echo 已分配启动分区盘符,按任意键卸载启动分区盘符
pause
echo select disk 0 >%temp%\remove.txt
echo select partition 1 >>%temp%\remove.txt
echo remove>>%temp%\remove.txt
echo exit>>%temp%\remove.txt
diskpart /s %temp%\remove.txt
echo 已卸载启动分区盘符,演示完毕
pause
exit
演示效果:
1. 笔者的计算机装有Windows 7。启动分区未分配盘符
2. 可以看到成功分配启动文件所在分区盘符
3. 成功卸载启动分区盘符。演示完毕
7.5.2 NT6.0使用批处理升级并配置启动项
获取启动分区盘符后,可以针对启动分区内的启动文件进行升级与配置。步骤有下列2项:
1. 升级boogmgr启动器文件,以支持基于VHD文件的Windows 8启动2. 编辑BCD启动项
以上2个步骤,解决较简单。
1. 找到bootmgr启动器文件,获取权限,删除并替换新bootmgr启动器文件(权限工具Windows 7内置)2. 这个问题笔者在上篇文章演示过。这里就不做介绍。(编辑BCD启动项信息使用的BCDEDIT工具Windows 7内置)
对第一点来说,Bootmgr启动文件Windows 7过旧,用户需提前准备。可将Windows 8的bootmgr存放于ftp,使用批处理下载。FTP批处理下载参考笔者上篇文章7.1。
批处理文件内容如下(假设启动盘是e,实际使用配合查找到的启动分区):
@echo off
takeown.exe /F e:\bootmgr /A
icacls.exe e:\bootmgr /grant Administrators:F
del e:\bootmgr /a /f /q
echo 权限获取成功,删除旧版boogmgr
pause
echo open 192.168.1.2> dbootmgr.txt
echo win8>> dbootmgr.txt
echo 123456>> dbootmgr.txt
echo lcd e:\>> dbootmgr.txt
echo get bootmgr>> dbootmgr.txt
echo bye>> dbootmgr.txt
ftp -s:dbootmgr.txt 1>nul
del dbootmgr.txt
echo 文件更新成功
pause
exit
演示效果:
1. 未更新时旧版bootmgr文件的修改时间是2010年
2. 删除旧版文件成功
3. 文件更新成功。可看到新文件的修改时间为2013年。至此,bootmgr更新演示完毕
接着,笔者在批处理内写入VHD启动信息。对比上篇批处理文件改动不大。笔者这里简单演示下。
注意。由于bcdedit命令语言问题,在上篇Windows XP系统下下载的bcdedit命令回显是英文,调用中文版Windows 7的bcdedit命令回显是中文,故截取启动项的GUID稍有不同。英文版GUID在回显第三列,中文版在回显第二列。故需注意将tokens=3改为2。
环境:
OS:Windows 7
VHD store:D:\win8ent.Vhd
批处理文件内容如下:
@echo off
FOR /F "tokens=2 delims= " %%i in ('bcdedit /create /d "Windows 8" /applicationosloader') do set _win8id=%%i
bcdedit /set %_win8id% device vhd=\win8ent.vhd
bcdedit /set %_win8id% osdevice vhd=\win8ent.vhd
bcdedit /set %_win8id% path \Windows\system32\winload.exe
bcdedit /set %_win8id% systemroot \windows
bcdedit /set %_win8id% locale zh-cn
bcdedit /displayorder %_win8id% /addlast
bcdedit /set {bootmgr} default %_win8id%
bcdedit /timeout 30
echo 成功添加基于VHD文件启动的Windows 8启动项
pause
exit
执行效果
1. 运行前的检查。可看到BCD文件的启动项只有Windows 7
2. 这次没有设置回显隐藏,可以看到命令成功执行。使用bcdedit打开BCD文件。可看到已成功添加笔者要求添加的启动信息。至此,添加启动项演示完毕。
7.5.3 卸载基于VHD文件启动Windows 8
通过以上介绍,员工DIY部署基于VHD文件启动的Windows 8,主要改动有以下2点:
1. 升级bootmgr2. 修改BCD信息,加入基于VHD文件启动Windows 8的启动信息3. 下载VHD文件到本机
要实现自动卸载功能,需对以上第2、3点进行逆向处理。第1点是不需要处理的。原因在于Windows 8的bootmgr启动器向下兼容。并且再次安装基于VHD文件启动的Windows 8。是否替换该文件也无影响。第二点与第三点笔者在上篇文章有过介绍,这里只做简单演示。
笔者假设VHD文件存放于分区D,名字为win8.vhd。批处理内容:
@echo off
bcdedit /delete {default}
echo 成功删除基于VHD文件启动的Windows 8启动项
del d:\win8.vhd /a /f /q
echo 成功删除基于VHD文件启动的Windows 8
pause
exit
演示效果:
1. 可看到,VHD文件存放于分区D。BCD有Windows 8的启动项
2. 运行批处理,基于VHD文件启动的Windows 8相关内容被清理。至此,卸载演示完毕
7.5.4 批处理的组合
考虑到批处理的合理性、员工的少操作性,并与上一篇文章内容配套。笔者对批处理文件组合采取了以下顺序:
1. 员工选择系统,来确认启动文件的部署方式与卸载方式2. 员工选择安装或卸载操作3. 员工选择分区,用于存放VHD。并记录VHD存放分区信息4. 批处理升级bootmgr启动器。并进行BCD文件修改5. 批处理自动下载VHD文件。
可以看到,改动并不大
首先,笔者用到的批处理文件如下:
1. index.bat 员工DIY安装文件。提供员工选择及调用相关批处理2. win7changiu.bat 被调用的批处理,提供选择安装或卸载基于VHD文件启动的windows 8功能3. win7instll.bat 被调用的批处理,提供自动安装NT6.0环境下、基于VHD文件启动的windows 8. (无隐藏启动分区)4. win7instll1.bat 被调用的批处理,提供自动安装NT6.0环境下、基于VHD文件启动的windows 8.(有隐藏启动分区)5. win7uninstall.bat 被调用的批处理,提供基于VHD文件启动的windows 8
其中,2、3、4、5这4个批处理文件笔者放于公司FTP服务器
笔者演示的环境:
服务器
OS:Windows Server 2003
Role:FTP Server
IP:192.168.1.2
Ftpuser:win8
ftp password :123456
客户机
OS:Windows 7
IP:192.168.100.128
批处理内容:
1. index.bat
@echo off
echo 本软件用来安装Windows8,退出请关闭本窗口
pause
:changeos
cls
echo 请选择您的操作系统
echo #####################################################
echo Windows XP请按1
echo Windows 7请按2
echo Windows XP与Windows 7双系统请按3
echo Windows XP与Windows XP请按1
echo Windows 7与Windows 7请按2
echo #####################################################
set cos=
set /p cos=请输入对应数字选择您的操作系统:
echo 您的输入的是:%cos%,
set /p chkcos=如果输入错误请按N,确认输入没错请按y,:
if "%chkcos%"=="n" goto changeos
if "%chkcos%"=="N" goto changeos
if "%chkcos%"=="y" goto next1
if "%chkcos%"=="Y" goto next1
echo 您输入有误,将返回重新输入
pause
goto changeos
:next1
if "%cos%"=="1" goto xp
if "%cos%"=="2" goto win7
if "%cos%"=="3" goto xp7
echo 您输入有误,将返回重新输入
pause
goto changeos
:xp
echo open 192.168.1.2> %temp%\vhdwin8xp.txt
echo win8>> %temp%\vhdwin8xp.txt
echo 123456>> %temp%\vhdwin8xp.txt
echo lcd %temp%>> %temp%\vhdwin8xp.txt
echo get xpchangiu.bat>> %temp%\vhdwin8xp.txt
echo bye>> %temp%\vhdwin8xp.txt
ftp -s:%temp%\vhdwin8xp.txt 1>nul
del /q %temp%\vhdwin8xp.txt
call %temp%\xpchangiu.bat
del /q %temp%\xpchangiu.bat
exit
:win7
echo open 192.168.1.2> %temp%\vhdwin8win7.txt
echo win8>> %temp%\vhdwin8win7.txt
echo 123456>> %temp%\vhdwin8win7.txt
echo lcd %temp%>> %temp%\vhdwin8win7.txt
echo get win7changiu.bat>> %temp%\vhdwin8win7.txt
echo bye>> %temp%\vhdwin8win7.txt
ftp -s:%temp%\vhdwin8win7.txt 1>nul
del /q %temp%\vhdwin8win7.txt
call %temp%\win7changiu.bat
del /q %temp%\win7changiu.bat
exit
:xp7
echo open 192.168.1.2> %temp%\vhdwin8xp7.txt
echo win8>> %temp%\vhdwin8xp7.txt
echo 123456>> %temp%\vhdwin8xp7.txt
echo lcd %temp%>> %temp%\vhdwin8xp7.txt
echo get xp7changiu.bat>> %temp%\vhdwin8xp7.txt
echo bye>> %temp%\vhdwin8xp7.txt
ftp -s:%temp%\vhdwin8xp7.txt 1>nul
del /q %temp%\vhdwin8xp7.txt
call %temp%\xp7changiu.bat
del /q %temp%\xp7changiu.bat
exit
2. win7changiu.bat
@echo off
:uni
cls
echo 请选择要进行的工作
echo #####################################################
echo 安装Windows 8请按 1
echo 卸载Windows 8请按 2
echo #####################################################
set unisos=
set /p unisos=请输入对应数字选择您的操作:
echo 您的输入的是:%unisos%,
set /p chkunisos=如果输入错误请按N,确认输入没错请按y,:
if "%chkunisos%"=="n" goto uni
if "%chkunisos%"=="N" goto uni
if "%chkunisos%"=="y" goto next2
if "%chkunisos%"=="Y" goto next2
echo 您输入有误,将返回重新输入
pause
goto uni
:next2
if "%unisos%"=="1" goto instll
if "%unisos%"=="2" goto uninstall
echo 您输入有误,将返回重新输入
pause
goto uni
:instll
echo open 192.168.1.2> %temp%\Win7instll.txt
echo win8>> %temp%\Win7instll.txt
echo 123456>> %temp%\Win7instll.txt
echo lcd %temp%>> %temp%\Win7instll.txt
echo get win7instll.bat>> %temp%\Win7instll.txt
echo bye>> %temp%\Win7instll.txt
echo 下载工具中。
ftp -s:%temp%\Win7instll.txt 1>nul
del /q %temp%\Win7instll.txt
call %temp%\win7instll.bat
del /q %temp%\win7instll.bat
exit
:uninstall
echo open 192.168.1.2> %temp%\win7uninstall.txt
echo win8>> %temp%\win7uninstall.txt
echo 123456>> %temp%\win7uninstall.txt
echo lcd %temp%>> %temp%\win7uninstall.txt
echo get win7uninstall.bat>> %temp%\win7uninstall.txt
echo bye>> %temp%\win7uninstall.txt
echo 下载工具中。
ftp -s:%temp%\win7uninstall.txt 1>nul
del /q %temp%\win7uninstall.txt
call %temp%\win7uninstall.bat
del /q %temp%\win7uninstall.bat
exit
3. win7instll.bat
@echo off
set _pf=_pf
:pf
cls
dir /a a:\bootmgr 1>nul 2>nul && set _pf=a
dir /a b:\bootmgr 1>nul 2>nul && set _pf=b
dir /a c:\bootmgr 1>nul 2>nul && set _pf=c
dir /a d:\bootmgr 1>nul 2>nul && set _pf=d
dir /a e:\bootmgr 1>nul 2>nul && set _pf=e
dir /a f:\bootmgr 1>nul 2>nul && set _pf=f
dir /a g:\bootmgr 1>nul 2>nul && set _pf=g
dir /a h:\bootmgr 1>nul 2>nul && set _pf=h
dir /a i:\bootmgr 1>nul 2>nul && set _pf=i
dir /a j:\bootmgr 1>nul 2>nul && set _pf=i
dir /a k:\bootmgr 1>nul 2>nul && set _pf=i
dir /a l:\bootmgr 1>nul 2>nul && set _pf=i
dir /a m:\bootmgr 1>nul 2>nul && set _pf=i
dir /a n:\bootmgr 1>nul 2>nul && set _pf=i
If %_pf%==_pf goto install1
If not %_pf%==_pf goto install2
goto pf
exit
:install1
cls
echo 获取启动分区盘符失败。现分配启动分区盘符
@echo off
echo select disk 0 >%temp%\assign.txt
echo select partition 1 >>%temp%\assign.txt
echo assign=>>%temp%\assign.txt
echo exit>>%temp%\assign.txt
diskpart /s %temp%\assign.txt
del %temp%\assign.txt /a /f /q
echo open 192.168.1.2> %temp%\Win7instll1.txt
echo win8>> %temp%\Win7instll1.txt
echo 123456>> %temp%\Win7instll1.txt
echo lcd %temp%>> %temp%\Win7instll1.txt
echo get win7instll1.bat>> %temp%\Win7instll1.txt
echo bye>> %temp%\Win7instll1.txt
ftp -s:%temp%\Win7instll1.txt 1>nul
del /q %temp%\Win7instll1.txt
call %temp%\win7instll1.bat
del /q %temp%\win7instll1.bat
del /q %temp%\win7instll.bat
exit
:install2
cls
echo 成功获取盘符%_pf%,开始自动部署基于VHD文件启动的Windows 8
takeown.exe /F %_pf%:\bootmgr /A
icacls.exe %_pf%:\bootmgr /grant Administrators:F
del %_pf%:\bootmgr /a /f /q
echo 权限获取成功,删除旧版boogmgr
echo open 192.168.1.2> %temp%\dbootmgr.txt
echo win8>> %temp%\dbootmgr.txt
echo 123456>> %temp%\dbootmgr.txt
echo lcd %_pf%:\>> %temp%\dbootmgr.txt
echo get bootmgr>> %temp%\dbootmgr.txt
echo bye>> %temp%\dbootmgr.txt
ftp -s:%temp%\dbootmgr.txt 1>nul
del %temp%\dbootmgr.txt
echo bootmgr启动器文件更新成功
goto ftp
:ftp
cls
echo 请打开计算机,确认要下载Win8的分区可用空间大于16G。
set vhdstore=
set /p vhdstore=请输入要下载到那个盘(如C盘请输入C。):
echo 您输入的字符串是:%vhdstore%,
set /p chkvhdstore=如果输入错误请按N,确认输入没错请按y,:
if "%chkvhdstore%"=="n" goto ftp
if "%chkvhdstore%"=="N" goto ftp
mkdir "%vhdstore%:\Windows 8 VHD"
goto bcd
:bcd
FOR /F "tokens=2 delims= " %%i in ('bcdedit /create /d "Windows 8" /application osloader') do set _win8id=%%i
bcdedit /set %_win8id% device vhd= "[%vhdstore%:]\Windows 8 VHD\win8ent.vhd"
bcdedit /set %_win8id% osdevice vhd= "[%vhdstore%:]\Windows 8 VHD\win8ent.vhd"
bcdedit /set %_win8id% path \Windows\system32\winload.exe
bcdedit /set %_win8id% systemroot \windows
bcdedit /set %_win8id% locale zh-cn
bcdedit /displayorder %_win8id% /addlast
bcdedit /set {bootmgr} default %_win8id%
bcdedit /timeout 30
cls
echo 成功添加基于VHD文件启动的Windows 8启动项
goto ftpvhd
:ftpvhd
echo open 192.168.1.2> %temp%\ftpvhd.txt
echo win8>> %temp%\ftpvhd.txt
echo 123456>> %temp%\ftpvhd.txt
echo lcd "%vhdstore%:\Windows 8 VHD">> %temp%\ftpvhd.txt
echo get win8ent.vhd>> %temp%\ftpvhd.txt
echo bye>> %temp%\ftpvhd.txt
echo 下载Win8时间较长,大概需要30分的时间。
ftp -s:%temp%\ftpvhd.txt 1>nul
del %temp%\ftpvhd.txt
echo 下载完毕。现在可以重启进入Windows 8
pause
exit
4. win7instll1.bat@echo off
set _pf1=_pf1
:pf1
cls
dir /a a:\bootmgr 1>nul 2>nul && set _pf1=a
dir /a b:\bootmgr 1>nul 2>nul && set _pf1=b
dir /a c:\bootmgr 1>nul 2>nul && set _pf1=c
dir /a d:\bootmgr 1>nul 2>nul && set _pf1=d
dir /a e:\bootmgr 1>nul 2>nul && set _pf1=e
dir /a f:\bootmgr 1>nul 2>nul && set _pf1=f
dir /a g:\bootmgr 1>nul 2>nul && set _pf1=g
dir /a h:\bootmgr 1>nul 2>nul && set _pf1=h
dir /a i:\bootmgr 1>nul 2>nul && set _pf1=i
dir /a j:\bootmgr 1>nul 2>nul && set _pf1=i
dir /a k:\bootmgr 1>nul 2>nul && set _pf1=i
dir /a l:\bootmgr 1>nul 2>nul && set _pf1=i
dir /a m:\bootmgr 1>nul 2>nul && set _pf1=i
dir /a n:\bootmgr 1>nul 2>nul && set _pf1=i
If %_pf1%==_pf1 goto error
If not %_pf1%==_pf1 goto installwin7
goto pf1
exit
:error
cls
echo 获取启动分区盘符失败!
echo 出现错误,请联系管理员!
pause
exit
:installwin7
cls
echo 成功获取盘符%_pf1%,开始自动部署基于VHD文件启动的Windows 8
takeown.exe /F %_pf1%:\bootmgr /A
icacls.exe %_pf1%:\bootmgr /grant Administrators:F
del %_pf1%:\bootmgr /a /f /q
echo 权限获取成功,删除旧版boogmgr
echo open 192.168.1.2> %temp%\dbootmgr.txt
echo win8>> %temp%\dbootmgr.txt
echo 123456>> %temp%\dbootmgr.txt
echo lcd %_pf1%:\>> %temp%\dbootmgr.txt
echo get bootmgr>> %temp%\dbootmgr.txt
echo bye>> %temp%\dbootmgr.txt
ftp -s:%temp%\dbootmgr.txt 1>nul
del %temp%\dbootmgr.txt
echo bootmgr启动器文件更新成功
echo select disk 0 >%temp%\remove.txt
echo select partition 1 >>%temp%\remove.txt
echo remove>>%temp%\remove.txt
echo exit>>%temp%\remove.txt
diskpart /s %temp%\remove.txt
echo 卸载启动分区盘符成功
goto ftp
:ftp
cls
echo 请打开计算机,确认要下载Win8的分区可用空间大于16G。
set vhdstore=
set /p vhdstore=请输入要下载到那个盘(如C盘请输入C。):
echo 您输入的字符串是:%vhdstore%,
set /p chkvhdstore=如果输入错误请按N,确认输入没错请按y,:
if "%chkvhdstore%"=="n" goto ftp
if "%chkvhdstore%"=="N" goto ftp
mkdir "%vhdstore%:\Windows 8 VHD"
goto bcd
:bcd
FOR /F "tokens=2 delims= " %%i in ('bcdedit /create /d "Windows 8" /application osloader') do set _win8id=%%i
bcdedit /set %_win8id% device vhd= "[%vhdstore%:]\Windows 8 VHD\win8ent.vhd"
bcdedit /set %_win8id% osdevice vhd= "[%vhdstore%:]\Windows 8 VHD\win8ent.vhd"
bcdedit /set %_win8id% path \Windows\system32\winload.exe
bcdedit /set %_win8id% systemroot \windows
bcdedit /set %_win8id% locale zh-cn
bcdedit /displayorder %_win8id% /addlast
bcdedit /set {bootmgr} default %_win8id%
bcdedit /timeout 30
cls
echo 成功添加基于VHD文件启动的Windows 8启动项
goto ftpvhd
:ftpvhd
echo open 192.168.1.2> %temp%\ftpvhd.txt
echo win8>> %temp%\ftpvhd.txt
echo 123456>> %temp%\ftpvhd.txt
echo lcd "%vhdstore%:\Windows 8 VHD">> %temp%\ftpvhd.txt
echo get win8ent.vhd>> %temp%\ftpvhd.txt
echo bye>> %temp%\ftpvhd.txt
echo 下载Win8时间较长,大概需要30分的时间。
ftp -s:%temp%\ftpvhd.txt 1>nul
del %temp%\ftpvhd.txt
echo 下载完毕。现在可以重启进入Windows 8
pause
exit
5. win7uninstall.bat@echo off
set _vhdfile=vhdfile
dir /a "a:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=a
dir /a "b:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=b
dir /a "c:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=c
dir /a "d:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=d
dir /a "e:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=e
dir /a "f:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=f
dir /a "g:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=g
dir /a "h:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=h
dir /a "i:\Windows 8 VHD\win8ent.vhd" 1>nul 2>nul && set _vhdfile=i
If %_vhdfile%==vhdfile goto quit
If not %_vhdfile%==vhdfile goto next3
exit
:next3
bcdedit /delete {default}
rd "%_vhdfile%:\Windows 8 VHD" /s /q
cls
echo Windows 8卸载完成
pause
exit
:quit
echo 您未通过本工具安装Windows 8.故无法卸载Windows 8
pause
exit
7.5.5 批处理的演示
演示效果:
1. 可看到,笔者的虚拟机安装了Windows 7。并无其他系统。启动分区为隐藏分区
2. 运行index.bat。按照设置出现傻瓜化提示。由于只是演示,故无太多细心考虑
3. 傻瓜化选择继续中(笔者这里手动删掉桌面先前测试的多余bat)
4. 输入存放VHD文件的分区盘符
5. 至此,所有输入完毕。批处理进入自动化处理中,开始自动连接FTP服务器下载VHD文件
6. 可以看到要下载的VHD临时文件。估计要下载20到30分
7. 下载完毕。可以看到启动项内自动添加分区D中基于VHD文件启动的Windows 8的启动信息。
8. 重新引导可看到Windows 8的选项
9. 选择后进入Windows 8。
10.最后附上打开磁盘管理及磁盘分区的截图。
至此,Windows 7隐藏启动分区、批处理部署基于VHD文件启动的Windows 8演示完毕
接下来,笔者将演示卸载基于VHD文件启动的Windows 8
1. 首先,进入Windows 7。运行批处理。选择卸载
2. 卸载成功。可以看到BCD里已删除Windows 8的启动信息。VHD文件也被删除
至此。所有内容演示完毕
在企业环境中,还有少部分计算机安装了XP与Windows 7双系统。正常情况下。双系统的启动文件是存放于隐藏分区。故批处理只需将本篇内容中有关隐藏分区的内容删掉、或者和本篇内容一致,加上判断语句即可。由于批处理基本与Windows 7下使用批处理员工DIY部署基于VHD文件启动的Windows 8相同。笔者就不再叙述。
8. 总结
至此,历时1周半,本系列终于完结。
本系列中,笔者对部署基于VHD文件启动Windows 8的各种方法做了详细介绍,并针对IT部门非正规化管理、公司内(非)IT专业人士、傻瓜化、自己DIY部署基于VHD文件启动的windows8的想法做了一些探讨。本系列所有内容也可用于部署基于VHD文件启动的Windows 7。希望读者在阅读完本系列后能感觉有所收获。
Lblneva2013.03.26 lblneva 发表于 2013-3-26 14:24 static/image/common/back.gif
4. win7instll1.bat
5. win7uninstall.bat
7.5.5 批处理的演示
好全的系列啊,全收藏了。谢谢分享! 不同的操作系统,引导不一致。这个非常重要 写得真好,收藏了 受教了,大侠 谢谢分享! 恭谨受教,虚心学习 写得太好了,我挺你 好全的系列啊
页:
[1]