|
小马 Win7PE 专用安装程序
请小马哥帮忙看看,“小马 Win7PE 专用安装程序”添加 WIM 启动菜单不成功,问题出在哪?
全部代码:
@echo off
pushd %~dp0
color 0b
set prog=小马 Win7PE 专用安装程序
set l1= ╭══════════════════╮
set l2= ╭══┤ 小马 Win7PE 专用安装程序 ├══╮
set l3= ║ ╰══════════════════╯ ║
set l4= ║ ║
set l5= ╟════════════════════════╢
set l6= ║ 版权所有:qintag.com ║
set l7= ╰────────────────────────╯
title %prog%
set pefile=Win7PE.iso
set logfile=peinstall.log
set addattr=attrib +h
set delattr=attrib -s -h -r
:checkos
if /i not "%os%."=="windows_nt." goto systemerro
::判断系统版本并设置theos
ver|find /i " 6.1">nul &&set winver=win7&& set theos=win7
ver|find /i " 6.0">nul &&set winver=vista&& set theos=vista
ver|find /i " 5.0">nul &&set winver=winnt&& set theos=2000
ver|find /i " 5.1">nul &&set winver=winnt&& set theos=xp
ver|find /i " 5.2">nul &&set winver=winnt&& set theos=2003
goto start
:systemerro
cls
echo.
echo.
echo 注意:未经测试,本软件可能不适用于非 windows pe/2000/xp/2003/vista/win7 操作系统。
echo 按回车键退出安装程序
pause >nul
exit
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:start
cls
title %prog%——安装
echo.
echo %l1%
echo %l2%
echo %l3%
echo %l4%
echo ║ 请选择安装方式: ║
echo %l4%
echo ║ [1] 普通安装/启动 (硬 盘 安 装) ║
echo ║ ║
echo ║ [2] 卸载 Win7PE 程序 ║
echo ║ ║
echo ║ [q] 退出安装 ║
echo %l5%
echo %l6%
echo %l7%
echo.
echo 您现在使用的是 windows %theos% 操作系统 !
if "%theos%"=="xp" echo ( 或 windows xp 核心的 Win7PE )
if "%theos%"=="2003" echo ( 或 windows 2003 核心的 Win7PE )
if "%theos%"=="vista" echo ( 请确保您拥有管理员权限以及关闭了uac,否则安装可能失败 )
if "%theos%"=="win7" echo ( 请确保您拥有管理员权限以及关闭了uac,否则安装可能失败 )
echo.
::set choice=
set /p choice= 请选择要进行的操作 (1/2/q) ,然后按回车:
if "%choice%"=="" goto start
if not "%choice%"=="" set choice=%choice:~0,1%
if /i "%choice%"=="1" goto hd
if /i "%choice%"=="2" goto uninstall
if /i "%choice%"=="q" exit
goto start
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:hd
if not exist ..\sources\Win7PE.WIM goto err2
set rp=
for %%i in (e d c) do if exist %%i:\config.sys set rp=%%i:
set pedir=%rp%\%pefile%
if exist %pedir% goto err1
if /i "%theos%"=="vista" (goto nt6_install) else (if /i "%theos%"=="win7" (goto nt6_install) else (goto nt5_install))
goto hd
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:err1
cls
title %prog%——卸载
echo.
echo %l1%
echo %l2%
echo %l3%
echo %l4%
echo ║ 您的硬盘中好像已经安装了 Win7PE,您想怎么办? ║
echo %l4%
echo ║ [1] 卸载原有的 Win7PE,并且重新安装。 ║
echo ║ [2] 卸载原有的 Win7PE,并且不再安装。 ║
echo ║ 返回首页,重新选择安装选项。 ║
echo ║ [q] 退出安装 ║
echo %l5%
echo %l6%
echo %l7%
echo.
set choice=
set /p choice= 请选择要进行的操作 (1/2/b/q) ,然后按回车:
if "%choice%"=="" goto err1
if not "%choice%"=="" set choice=%choice:~0,1%
if /i "%choice%"=="1" set choi=1&&goto uninstall
if /i "%choice%"=="2" goto uninstall
if /i "%choice%"=="b" goto start
if /i "%choice%"=="q" exit
goto err1
exit
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:err2
cls
title %prog%——找不到文件Win7PE.WIM
echo.
echo.
echo.
echo.
echo 请将此安装文件放在\sources目录下,并检查此Win7PE的目录结构
echo.
echo.
echo 按任意键退出...&&pause >nul
exit
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:uninstall
set rp=
for %%i in (e d c) do if exist %%i:\config.sys set rp=%%i:
if exist %rp%\%logfile% for /f "eol=; tokens=2 delims=^=" %%i in ('find /i ^"Win7PE外挂位置^" %rp%\%logfile%') do set opd=%%i
if not "%u%"=="" set opd=%rp%
if exist %rp%\%pefile% %delattr% %rp%\%pefile%&&del %rp%\%pefile% /q>nul 2>nul
if exist %rp%\grldr %delattr% %rp%\grldr&&del %rp%\grldr /q>nul 2>nul
if exist %rp%\grldr.mbr %delattr% %rp%\grldr.mbr&&del %rp%\grldr.mbr /q>nul 2>nul
if exist %rp%\menu.lst %delattr% %rp%\menu.lst&&del %rp%\menu.lst /q>nul 2>nul
if exist %rp%\%logfile% %delattr% %rp%\%logfile%&&del %rp%\%logfile% /q>nul 2>nul
if exist %rp%\Win7PE.iso %delattr% %rp%\Win7PE.iso&&del %rp%\Win7PE.iso /q>nul 2>nul
if exist %opd%\Win7PE rd %opd%\Win7PE /s /q>nul 2>nul
find /i "%rp%\Win7PE" %rp%\boot.ini>nul 2>nul
if "%errorlevel%"=="0" %delattr% %rp%\boot.ini&&del %rp%\boot.ini
%delattr% %rp%\boot.ini>nul 2>nul
if /i "%theos%"=="vista" (%delattr% %rp%\boot.ini&&del %rp%\boot.ini>nul 2>nul)
if /i "%theos%"=="win7" (%delattr% %rp%\boot.ini&&del %rp%\boot.ini>nul 2>nul)
if exist %rp%\boot.bak (
%delattr% %rp%\boot.bak
type %rp%\boot.bak|find /i /v "%rp%\Win7PE">%rp%\boot.ini
) else (
if exist %rp%\boot.ini copy %rp%\boot.ini %rp%\boot.bak /y>nul 2>nul
if exist %rp%\boot.bak type %rp%\boot.bak|find /i /v "c:\Win7PE">%rp%\boot.ini
)
if exist %rp%\boot.bak %delattr% %rp%\boot.bak&&del %rp%\boot.bak>nul 2>nul
if exist %rp%\boot.ini %addattr% %rp%\boot.ini >nul 2>nul
set rp=
title %prog%——卸载完成
echo.&&echo.&&echo 卸载完成,请按任意键退出 。。。
pause>nul 2>nul
exit
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:nt6_install
cls
echo.
echo.
echo.
echo.
echo.
echo ║ 请选择 Win7PE 引导方式: ║
echo.
echo ║ [a] bootmbr 引导 WIM 方式 ║
echo ║ ║
echo ║ Grub 引导 ISO 方式 ║
echo ║ ║
echo ║ [e] 退出安装 ║
echo.
echo.
echo.
echo.
::set choice=
set /p choice= 请选择要进行的操作 (a/b/e) ,然后按回车:
if "%choice%"=="" goto start
if not "%choice%"=="" set choice=%choice:~0,1%
if /i "%choice%"=="a" goto nt6_bootmbr
if /i "%choice%"=="b" goto nt6_iso
if /i "%choice%"=="e" exit
goto nt6_install
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:nt6_iso
title %prog%——安装到NT6x系统下,ISO启动
if "%op%"=="" call :setextra
echo.
echo 正在复制文件,请稍等...
echo.
if not "%op%"=="" xcopy ..\WinPE /e %op%\WinPE\ /y /h /r>nul 2>nul
copy menu.lst %rp%\menu.lst /y>nul 2>nul
copy grldr %rp%\grldr /y>nul 2>nul
copy grldr.mbr %rp%\grldr.mbr /y>nul 2>nul
md %rp%\temp_pe3
md %rp%\temp_pe3\sources
copy ..\bootmgr %rp%\temp_pe3\bootmgr /y>nul 2>nul
xcopy ..\boot /e %rp%\temp_pe3\boot\ /y /h /r>nul 2>nul
copy ..\sources\Win7PE.WIM %rp%\temp_pe3\sources\Win7PE.WIM /y>nul 2>nul
cls
echo.
echo 正在制作iso镜像,请稍等...
echo.
oscdimg.exe -b"pe.bif" -h -n -lxmWinPE -o -t01/01/2012,00:00:00 "%rp%\temp_pe3" "%rp%\Win7PE.iso"
if not exist %rp%\boot.ini copy boot.ini %rp%\boot.ini /y>nul 2>nul
if exist %rp%\temp_pe3 rd %rp%\temp_pe3 /s /q>nul 2>nul
if "%u%"=="" call :pelog
goto success
:nt6_bootmbr
title %prog%——安装到NT6x系统下,WIM启动
if "%op%"=="" call :setextra
echo.
echo 正在复制文件,请稍等...
echo.
copy ..\sources\Win7PE.WIM %rp%\Win7PE.WIM /y>nul 2>nul
copy ..\boot\boot.sdi %rp%\boot.sdi /y>nul 2>nul
rem 建立win7pe_wim开机菜单启动项....
set bcddir=/store %rp%\boot\bcd
bcdedit %bcddir% /create {ramdiskoptions} /d "Windows 7 PE Edition"
bcdedit %bcddir% /set {ramdiskoptions} ramdisksdidevice partition=%rp%
bcdedit %bcddir% /set {ramdiskoptions} ramdisksdipath \boot.sdi
for /f "delims={,} tokens=2" %%a in ('bcdedit %bcddir% -create /d "Windows 7 PE Edition" -application osloader ') do set w7peid={%%a}
bcdedit %bcddir% -set %w7peid% device ramdisk="[%rp%]\Win7PE.wim,{ramdiskoptions}"
bcdedit %bcddir% -set %w7peid% osdevice ramdisk="[%rp%]\Win7PE.wim,{ramdiskoptions}"
bcdedit %bcddir% -set %w7peid% path \windows\system32\boot\winload.exe
bcdedit %bcddir% -set %w7peid% locale zh-CN
bcdedit %bcddir% -set %w7peid% inherit {bootloadersettings}
bcdedit %bcddir% -set %w7peid% systemroot \windows
bcdedit %bcddir% -set %w7peid% detecthal yes
bcdedit %bcddir% -set %w7peid% winpe yes
bcdedit %bcddir% -set %w7peid% ems yes
bcdedit %bcddir% -displayorder %w30id% -addlast
:nt5_install
title %prog%——安装到NT5x系统下
if "%op%"=="" call :setextra
echo.
echo 正在复制文件,,请稍等...
if not "%op%"=="" xcopy ..\WinPE /e %op%\WinPE\ /y /h /r>nul 2>nul
copy menu.lst %rp%\menu.lst /y>nul 2>nul
copy grldr %rp%\grldr /y>nul 2>nul
md %rp%\temp_pe3
md %rp%\temp_pe3\sources
copy ..\bootmgr %rp%\temp_pe3\bootmgr /y>nul 2>nul
xcopy ..\boot /e %rp%\temp_pe3\boot\ /y /h /r>nul 2>nul
copy ..\sources\Win7PE.WIM %rp%\temp_pe3\sources\Win7PE.WIM /y>nul 2>nul
cls
echo.
echo 正在制作iso镜像,请稍等...
echo.
oscdimg.exe -b"pe.bif" -h -n -lWin7PE -o -t01/01/2012,00:00:00 "%rp%\temp_pe3" "%rp%\Win7PE.iso"
if exist %rp%\boot.ini %delattr% %rp%\boot.ini
if exist %rp%\boot.ini if exist %rp%\boot.bak %delattr% %rp%\boot.bak
if exist %rp%\boot.ini copy %rp%\boot.ini %rp%\boot.bak>nul 2>nul
if exist %rp%\boot.ini echo %rp%\grldr="Windows 7 PE Edition">>%rp%\boot.ini
if exist %rp%\temp_pe3 rd %rp%\temp_pe3 /s /q>nul 2>nul
if "%u%"=="" call :pelog
goto success
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:success
title %prog%——安装完成
cls
echo.
echo 已经成功将 Win7PE 安装到您的本地硬盘。
echo.
if "%u%"=="" (
echo 外置程序 文件夹按照您的设置,复制到了 %op% 盘。
echo.
if exist %rp%\boot.ini echo 系统分区中的boot.ini备份为boot.bak。(多系统同上,如果是vista系统,添加的boot.ini,卸载时会删除)
)
echo.&&echo.
echo 如果您需要将 Win7PE 卸载,请重新运行本安装程序。
echo.
echo 请按任意键退出......
pause>nul 2>nul
exit
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:setextra
cls
if "%noop%"=="yes" echo 错误:您设定的分区不存在或写保护,请按任意键重新设定。&&echo.
set /p op=请设定 外置程序 存放的分区符[不需要冒号,例如 d(推荐)]:
echo.&&echo.
if "%op%"=="" goto setextra
if not "%op%"=="" set op=%op:~0,1%:
set testfile=%op%\imgtest_%random%.mt
cd.>%testfile%
if not exist %testfile% set noop=yes&&goto setextra
del %testfile% /q>nul 2>nul
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:pelog
>%rp%\%logfile% cd.
>>%rp%\%logfile% echo ;此文件为 Win7PE 的安装logfile,请不要随意删除
>>%rp%\%logfile% echo ;否则可能会造成 Win7PE 的卸载不够彻底!!!
>>%rp%\%logfile% echo.
>>%rp%\%logfile% echo Win7PE镜像文件=%pefile%
>>%rp%\%logfile% echo Win7PE外挂位置=%op%
>>%rp%\%logfile% echo Win7PE安装日期=%date% %time%
%addattr% %rp%\%logfile%
goto :eof |
|