|
试下下面的代码。例文件在,F:\sources\boot.wim,输入F就行了。
IWH.bat
- @echo off
- rem 硬盘安装Windows时,在现用系统上添加启动要安装系统的boot.wim
- rem 管理者模式启动仍保持工作路径为脚本所在目录
- cd /d "%~dp0"
- set TEST_OPT=1
- set /p WINISODRV=请输入安装文件所在盘符(例如:F):
- :BM_CHOOICE
- echo 请选择启动模式:
- echo 1.Legacy BIOS-based 模式(MBR引导)
- echo 2.UEFI-based 模式(EFI引导)
- set /p bootmode=
- if "%bootmode%"=="1" goto :BCD_EDIT
- if "%bootmode%"=="2" goto :BCD_EDIT
- goto :BM_CHOOICE
- :BCD_EDIT
- if "%bootmode%"=="1" set bootmode=LEGACY
- if "%bootmode%"=="2" set bootmode=EFI
- rem 指定测试选项,创建用于测试的BCD文件
- if not "%TEST_OPT%"=="" (
- rem 备份当前系统BCD
- bcdedit > ".\SYS_BCD.txt"
- bcdedit /export ".\SYS_BCD.bak"
- set TMP_BCD=.\TEST_BCD
- )
- if not "%TEST_OPT%"=="" (
- del /f /q %TMP_BCD%
- bcdedit /createstore %TMP_BCD%
- set TEST_OPT=/store %TMP_BCD%
- )
- if "bootmode"=="LEGACY" goto :BCD_LEGACY
- if "bootmode"=="EFI" goto :BCD_EFI
- :BCD_LEGACY
- echo 创建安装程序 Ramdisk 选项
- bcdedit %TEST_OPT% /create {ramdiskoptions} /d "Ramdisk Options"
- bcdedit %TEST_OPT% /set {ramdiskoptions} ramdisksdidevice partition=%WINISODRV%:
- bcdedit %TEST_OPT% /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
- for /f "tokens=2 delims={}" %%i in ('bcdedit %TEST_OPT% /create /d "Windows Boot" /application osloader') do (
- set LOADER_GUID={%%i}
- )
- echo GUID:%LOADER_GUID%
- if "%LOADER_GUID%"=="" goto :ErrorExit
- echo 创建Windows 启动加载器
- bcdedit %TEST_OPT% /set %LOADER_GUID% device ramdisk=[%WINISODRV%:]\sources\boot.wim,{ramdiskoptions}
- bcdedit %TEST_OPT% /set %LOADER_GUID% path \windows\system32\winload.exe
- bcdedit %TEST_OPT% /set %LOADER_GUID% description "Windows Setup"
- bcdedit %TEST_OPT% /set %LOADER_GUID% locale zh-CN
- bcdedit %TEST_OPT% /set %LOADER_GUID% inherit {bootloadersettings}
- bcdedit %TEST_OPT% /set %LOADER_GUID% osdevice ramdisk=[%WINISODRV%:]\sources\boot.wim,{ramdiskoptions}
- bcdedit %TEST_OPT% /set %LOADER_GUID% systemroot \windows
- bcdedit %TEST_OPT% /set %LOADER_GUID% detecthal yes
- bcdedit %TEST_OPT% /set %LOADER_GUID% winpe yes
- bcdedit %TEST_OPT% /set %LOADER_GUID% ems no
- if "%TEST_OPT%"=="" (
- bcdedit %TEST_OPT% /displayorder %LOADER_GUID% /addlast
- )
- goto :BCD_END
- :BCD_EFI
- echo COPY FILE(未实现)
- echo 请选择 1.Legacy BIOS-based 模式
- goto :BM_CHOOICE
- exit 0
- :BCD_END
- if not "%TEST_OPT%"=="" (
- echo 确认添加的引导信息
- bcdedit %TEST_OPT% /enum all
- echo 确认信息无误后,按任意键将引导信息添加到系统启动菜单
- pause
- set TEST_OPT=
- goto :BCD_EDIT
- )
- echo 添加引导信息到系统启动菜单成功
- pause
复制代码 |
|