|
   
- 帖子
- 1325
- 积分
- 5833
- 坛币
- 3264 元
- 在线时间
- 844 小时
- 注册时间
- 2008-10-2
- 最后登录
- 2010-1-5
 
|
沙发
发表于 2009-3-22 02:25
| 只看该作者

本帖最后由 chzhlh 于 2009-7-19 01:27 编辑
老教程为了一起说明VISTA/2008的安装方法,说得太多太详细变复杂了.不少朋友看得头晕脑胀,所以新开一贴.顺便占楼备用.
原贴:http://bbs.ruanmei.com/thread-132461-1-1.html,有兴趣看综合教程的在一楼,原始教程在二楼
鉴于有朋友要看源码,一段批处理而已,v2.6的源码,写得不好,见笑了.
rem >nul
cls
@echo off
mode con cols=80 lines=25
setlocal enabledelayedexpansion
color 1f
chcp 936>nul
if !errorlevel! equ 0 goto start
chcp 950>nul
if !errorlevel! equ 0 goto start
if %windir:~0,2% equ X: goto start
cls
echo.
echo Please Change your System Non-Unicode to [Simplified Chinese]
echo.
echo or [Traditional Chinese]
echo.
echo Press any key to Continue ......
pause >nul
:start
chcp 950 >nul
if !errorlevel! gtr 0 (
chcp 936
set line1=╭─────────────────────────────────────╮
set line2=│ │
set line3=╰─────────────────────────────────────╯
set msg1=安装/卸载程序
set msg2=当前系统:Vista/2008/Win7,推荐使用模式 2
set msg3=错误!!!请关闭UAC或右击本程序后以管理员身份运行,按键退出......
set msg4=按键返回主界面......
set msg5=│[1] 安装 nt6 hdd Installer 模式 1 : 当前系统为2000/xp/2003时推荐使用 │
set msg5_1=│[2] 安装 nt6 hdd Installer 模式 2 : 当前系统为vista/2008/7/PE时推荐使用 │
set msg6=│[3] 卸载 nt6 hdd Installer 模式 1 和模式 2 │
set msg6_a=│[4] 退出 │
set msg6_0=│ 安装前请确认已经把vista/2008/win7安装程序提取/解压至本地硬盘某分区根目录 │
set msg6_1= 模式说明:可以选择安装其中一种或两种模式同时安装
set msg7=请选择要进行的操作 [1/2/3/4] ,然后按回车:
set msg10=当前系统:2000/XP/2003,推荐使用模式 1
set msg11=当前系统:WinPE,暂只能使用模式 2
set msg12=错误:未知原因找不到启动菜单配置文件boot.ini,启动菜单未添加
set msg13=模式 1 安装完成
set msg13_1=模式 2 安装完成
set msg14=重启选择 nt6 hdd Installer mode 1 进行系统安装
set msg14_1=重启选择 nt6 hdd Installer mode 2 [EMS Enable] 进行系统安装
set msg16=本操作将同时卸载 nt6 hdd Installer 模式 1 和模式 2
set msg18=卸载完成,
set msg19=系统BCD存在错误,无法添加启动菜单,使用BCDautofix^(v1.0.3或更高版本^)进行修复
set msg20=BCD后再次尝试安装 或 使用原始方法^(Vista HDD Installer^),按键退出...
set msg24=PE系统中暂不支持安装模式 1,如有特别需要,请安装模式 2,
set msg25=错误:在所有有效盘符中没发现Vista/2008/Win7安装程序,请将Vista/2008/Win7安
set msg26=装程序提取至本地硬盘某分区根目录后再次安装模式 2
set msg27=上发现Vista/2008/Win7安装程序
set msg28=模式 2 未知原因安装失败!!!
) else (
chcp 950
set line1=ⅰ
set line2=
set line3=ⅱⅲ
set msg1=杆/更祘
set msg2=讽玡╰参Vista/2008/Win7崩ㄏノ家Α 2
set msg3=岿粇叫闽超UAC┪阑セ祘╰参恨瞶ō笲︽龄癶......
set msg4=龄......
set msg5=[1] 杆 nt6 hdd Installer 家Α 1 : 讽玡╰参2000/xp/2003崩ㄏノ
set msg5_1=[2] 杆 nt6 hdd Installer 家Α 2 : 讽玡╰参vista/2008/7/PE崩ㄏノ
set msg6=[3] 更 nt6 hdd Installer 家Α 1 ㎝家Α 2
set msg6_a=[4] 癶
set msg6_0= 杆玡叫絋粄竒рvista/2008/win7杆祘Α矗/秆溃セ祑絃琘だ跋ヘ魁
set msg6_1= 家Α弧:匡拒杆ㄤい贺┪ㄢ贺家Α杆
set msg7=叫匡拒璶秈︽巨 [1/2/3/4] 礛ó
set msg10=讽玡╰参2000/XP/2003崩ㄏノ家Α 1
set msg11=讽玡╰参WinPE既ㄏノ家Α 2
set msg12=岿粇:ゼтぃ秨诀垫虫皌竚ゅンboot.ini秨诀垫虫ゼ睰
set msg13=家Α 1 杆ЧΘ
set msg13_1=家Α 2 杆ЧΘ
set msg14=币匡拒 nt6 hdd Installer mode 1 秈︽╰参杆
set msg14_1=币匡拒 nt6 hdd Installer mode 2 [EMS Enable] 秈︽╰参杆
set msg16=セ巨盢更 nt6 hdd Installer 家Α 1 ㎝家Α 2
set msg18=更ЧΘ
set msg19=╰参BCD岿粇礚猭睰秨诀垫虫ㄏノBCDautofix^(v1.0.3┪蔼セ^)秈︽蝋
set msg20=BCDΩ沽刚杆 ┪ ㄏノ﹍よ猭^(Vista HDD Installer^)龄癶...
set msg24=PE╰参い既ぃや杆家Α 1Τ疭惠璶叫杆家Α 2
set msg25=岿粇┮ΤΤ絃才い⊿祇瞷Vista/2008/Win7杆祘叫盢Vista/2008/Win7
set msg26=杆祘矗セ祑絃琘だ跋ヘ魁Ω杆家Α 2
set msg27=祇瞷Vista/2008/Win7杆祘
set msg28=家Α 2 ゼ杆ア毖
)
cls
title nt6 hdd Installer v2.6 !msg1! by chzhlh
echo.
if %windir:~0,2% equ X: (
if exist c:\boot\bcd (
be >nul
if !errorlevel! gtr 0 echo !msg19! &echo. &echo !msg20! &echo. &pause>nul &exit)
set /a wver=0
set driverall=C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: Y: Z:
set msg100=!msg11!
) else (
if exist %windir%\system32\slmgr.vbs (
if exist nt6hdd.temp.* attrib -r -h -s nt6hdd.temp.* >nul & del nt6hdd.temp.* >nul
be /createstore nt6hdd.temp >nul
if !errorlevel! gtr 0 echo !msg2! &echo. &echo !msg3! & pause>nul &exit
set /a wver=6
set driverall=A: B: C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:
set msg100=!msg2!
be >nul
if !errorlevel! gtr 0 echo !msg19! &echo. &echo !msg20! &echo. &pause>nul &exit
) else (
if exist c:\boot\bcd (
be >nul
if !errorlevel! gtr 0 echo !msg19! &echo. &echo !msg20! &echo. &pause>nul &exit)
set /a wver=5
set driverall=C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:
set msg100=!msg10!)
)
set vhiuid={66666666-fa0f-11da-8ddf-001320035401}
set vhiuid1={77777777-fa0f-11da-8ddf-001320035401}
set vhiuid2={88888888-fa0f-11da-8ddf-001320035401}
:begin
cls
echo !line1!
echo !msg6_0!
echo !line3!
echo.
echo !msg6_1!
echo.
echo !line1!
echo !msg5!
echo !line2!
echo !msg5_1!
echo !line2!
echo !msg6!
echo !line2!
echo !msg6_a!
echo !line3!
echo.
set coi=
set coi1=
echo !msg100!
echo.
Set /P coi= !msg7!
set coi1=%Coi:~0,1%
if /i "!coi1!"=="1" goto install
if /i "!coi1!"=="2" goto install2
if /i "!coi1!"=="3" goto uninstall
if /i "!coi1!"=="4" goto quitt
goto begin
:install
echo.
if !wver! equ 0 (
echo !msg24!!msg4!
pause >nul
goto begin
)
if !wver! equ 6 (
if not exist c:\zchzr xcopy /y zchzr c:\ >nul
if not exist c:\zchzr.mbr xcopy /y zchzr.mbr c:\ >nul
be /create %vhiuid% /d "nt6 hdd Installer mode 1" /application bootsector >nul
be /set %vhiuid% device partition=c: >nul
be /set %vhiuid% path \zchzr.mbr >nul
be /displayorder %vhiuid% /addlast >nul
be /timeout 8 >nul
)
if !wver! equ 5 (
if not exist c:\boot.ini echo !msg12! &echo. &echo !msg4! &pause>nul &goto begin
if not exist c:\zchzr xcopy /y zchzr c:\ >nul
if not exist c:\zchzr.mbr xcopy /y zchzr.mbr c:\ >nul
type c:\boot.ini|find "zchzr.mbr" /i >nul
if !errorlevel! gtr 0 (
attrib -h -r -s c:\boot.ini >nul
copy /y c:\boot.ini %temp%\boot.ini.vhi >nul
echo [boot loader] >c:\boot.ini
echo timeout=8 >>c:\boot.ini
type %temp%\boot.ini.vhi|find "loader]" /i /v|find "timeout" /i /v|find ";" /i /v >>c:\boot.ini
echo c:\zchzr.mbr="nt6 hdd Installer mode 1">>c:\boot.ini
attrib +s +h c:\boot.ini >nul
)
)
attrib +r +h +s c:\zchzr.*
echo ======================================================================
echo.
echo nt6 hdd Installer !msg13!
echo.
echo !msg14!
echo.
echo !msg4! & pause>nul & goto begin
:install2
echo.
set /a foundsources=0
for %%A in (!driverall!) do (
if !foundsources! equ 0 (
if exist %%A\boot\boot.sdi (
if exist %%A\sources\setup.exe (
if exist %%A\bootmgr (
if exist nt6hdd.temp.* attrib -r -h -s nt6hdd.temp.* >nul & del nt6hdd.temp.*
be /createstore nt6hdd.temp >nul
be /store nt6hdd.temp /create {bootmgr} /d "Drivetest" >nul
be /store nt6hdd.temp /set {bootmgr} device partition=%%A >nul
if !errorlevel! equ 0 (
set sourcesdrive=%%A
set /a foundsources=1
))))))
if !foundsources! equ 0 echo !msg25! &echo !msg26! &echo. &echo !msg4! &pause>nul &goto begin
echo !sourcesdrive!!msg27!
echo.
echo ======================================================================
if !wver! neq 6 (
if not exist c:\boot\bcd (
if exist nt6hdd.temp.* attrib -r -h -s nt6hdd.temp.* >nul & del nt6hdd.temp.*
be /createstore nt6hdd.temp >nul
be /import nt6hdd.temp >nul
be /create {bootmgr} /d "Windows Boot Manager" >nul
be /set {bootmgr} device boot >nul
)
if not exist c:\bootmgr (attrib -h -s !sourcesdrive!\bootmgr >nul © !sourcesdrive!\bootmgr c:\ >nul)
)
echo.
be /create %vhiuid1% /d "nt6 hdd Installer mode 2" /device >nul
be /set %vhiuid1% ramdisksdidevice partition=!sourcesdrive! >nul
be /set %vhiuid1% ramdisksdipath \boot\boot.sdi >nul
be /create %vhiuid2% /d "nt6 hdd Installer mode 2 [EMS Enable]" /application osloader >nul
be /set %vhiuid2% device ramdisk=[!sourcesdrive!]\sources\boot.wim,%vhiuid1% >nul
be /set %vhiuid2% path \windows\system32\boot\winload.exe >nul
be /set %vhiuid2% locale en-US >nul
be /set %vhiuid2% osdevice ramdisk=[!sourcesdrive!]\sources\boot.wim,%vhiuid1% >nul
be /set %vhiuid2% systemroot \windows >nul
be /set %vhiuid2% detecthal Yes >nul
be /set %vhiuid2% winpe Yes >nul
be /set %vhiuid2% ems Yes >nul
be /displayorder %vhiuid2% /addlast >nul
be | find "!vhiuid2!" >nul
if !errorlevel! gtr 0 (
echo nt6 hdd installer !msg28!
echo.
echo !msg4! & pause>nul & goto begin
)
be /timeout 8 >nul
if !wver! equ 5 (
be /create {ntldr} /d "Earlier Version of Windows" >nul
be /set {ntldr} device boot >nul
be /set {ntldr} path \ntldr >nul
be /displayorder {ntldr} /addfirst >nul
be /default {ntldr} >nul
)
if !wver! equ 0 (
if exist c:\ntldr (
be /create {ntldr} /d "Earlier Version of Windows" >nul
be /set {ntldr} device boot >nul
be /set {ntldr} path \ntldr >nul
be /displayorder {ntldr} /addfirst >nul
be /default {ntldr} >nul
))
if exist c:\bootmgr (
if !wver! equ 5 (bs /nt60 c: >nul)
if !wver! equ 0 (bs /nt60 c: /mbr >nul)
)
echo nt6 hdd Installer !msg13_1!
echo.
echo !msg14_1!
echo.
echo !msg4! & pause>nul & goto begin
:uninstall
echo.
echo !msg16!
echo.
be /delete %vhiuid% /f >nul
for %%A in (!driverall!) do (
if exist %%A\zchzr attrib -r -h -s %%A\zchzr &del %%A\zchzr >nul
if exist %%A\zchzr.mbr attrib -r -h -s %%A\zchzr.mbr &del %%A\zchzr.mbr >nul
if exist %%A\boot.ini (
type %%A\boot.ini|find "zchzr.mbr" /i >nul
if !errorlevel! equ 0 (
attrib -r -h -s %%A\boot.ini >nul
copy /y %%A\boot.ini %temp%\boot.ini.unc >nul
type %temp%\boot.ini.unc|find "zchzr.mbr" /i /v >%%A\boot.ini
attrib +h +s %%A\boot.ini >nul
)
)
)
echo ======================================================================
echo.
be /delete !vhiuid1! /f >nul
be /delete !vhiuid2! /f >nul
if !wver! neq 6 (
be /enum bootmgr | find /n /i "displayorder" >nt6hdd.temp
be /enum bootmgr | find /n /i "timeout" >>nt6hdd.temp
find /i "[8]displayorder" nt6hdd.temp >nul && set /a aa=1 || set /a aa=0
find /i "[9]timeout" nt6hdd.temp >nul && set /a bb=1 || set /a bb=0
set /a aa=!aa!+!bb!
if !aa! equ 2 (
find /i "[8]displayorder" nt6hdd.temp | find /i "ntldr" >nul
if !errorlevel! equ 0 (
if exist c:\ntldr (
bs /nt52 c:>nul
))))
echo !msg18!!msg4! &pause>nul &goto begin
:quitt
set coi=%Coi:~0,5%
if /i "!coi!"=="4NT52" goto i1
if /i "!coi!"=="4NT60" goto i2
exit
:i1
if !wver! equ 6 goto begin
if not exist c:\ntldr goto begin
cls
echo.
bs /nt52 c: >nul
if !errorlevel! equ 0 (echo. &echo Change Boot Record to NT52...OK) else (echo Change Boot Record to NT52...Error)
echo.
echo Press any key to Exit......
pause >nul
exit
:i2
if !wver! neq 6 (
if not exist c:\bootmgr exit
if not exist c:\boot\bcd exit
)
cls
echo.
if !wver! neq 6 (bs /nt60 c: >nul) else (bs /nt60 sys >nul)
if !errorlevel! equ 0 (echo. &echo Change Boot Record to NT60...OK) else (echo Change Boot Record to NT60...Error)
echo.
echo Press any key to Exit......
pause >nul
exit
模式1的原理很早就已经介绍过了(http://bbs.ruanmei.com/thread-132461-1-1.html二楼),现在介绍一下模式2的基本工作流程.
当前系统为VISTA/2008/WIN7/2008R2时,安装程序在E盘根目录为例
利用BCDEDIT为E盘的安装程序添加一个启动菜单就可以了.下面是实现批处理
set vhiuid1={66666666-fa0f-11da-8ddf-001320035401}
set vhiuid2={77777777-fa0f-11da-8ddf-001320035401}
bcdedit /create %vhiuid1% /d "nt6 hdd Installer mode 2" /device >nul
bcdedit /set %vhiuid1% ramdisksdidevice partition=e: >nul
bcdedit /set %vhiuid1% ramdisksdipath \boot\boot.sdi >nul
bcdedit /create %vhiuid2% /d "nt6 hdd Installer mode 2 [EMS Enable]" /application osloader >nul
bcdedit /set %vhiuid2% device ramdisk=[e:]\sources\boot.wim,%vhiuid1% >nul
bcdedit /set %vhiuid2% path \windows\system32\boot\winload.exe >nul
bcdedit /set %vhiuid2% locale en-US >nul
bcdedit /set %vhiuid2% osdevice ramdisk=[e:]\sources\boot.wim,%vhiuid1% >nul
bcdedit /set %vhiuid2% systemroot \windows >nul
bcdedit /set %vhiuid2% detecthal Yes >nul
bcdedit /set %vhiuid2% winpe Yes >nul
bcdedit /set %vhiuid2% ems Yes >nul
bcdedit /displayorder %vhiuid2% /addlast >nul
pause
这个批处理右击执行后就可以添加mode2的启动菜单,重启调用e盘上的系统安装程序并进入安装界面,也从多次的试验上证明低版本的bootmgr文件可以调用高版本的系统安装程序.所以无需替换bootmgr等操作.其实原理非常简单,只是之前大家没想到而已,想到了并说明了就没什么特别之处了.
如果当前系统是2000/xp/2003,添加mode2的手工操作相对繁琐一些,这里就不介绍了,不过玩多系统的朋友应该一看就明白.
集成做为一个工具发布,只是为不同的朋友不同的系统情况作出不同的操作 |
|