|
本批处理,和相关文件,放在同一个目录,(这个是原版,可去掉热拷贝部分,只用导入驱动,打包等)
就可以离线制作了. 关键就是导入注册表部分.
@ECHO OFF
color 2f
cd /d "%~dp0"
set wimpath=D:\QiRAMW7
set wimname=C:\boot\QiRAMW7.wim
ECHO 说 明
ECHO ---------------------------------------------------------
ECHO.
ECHO Qi_WIM_RAM_Win7 三合一 V 4.2 。
ECHO.
ECHO 安装、移植、热备份 WIN7 32位系统为 WIM 的内存系统 。
ECHO.
ECHO 直接在当前系统下安装,安装完即可使原系统在内存中运行 。
ECHO.
ECHO 建议系统经过必要的优化和垃圾文件的清理。
ECHO.
ECHO 请关闭所有打开的程序,注意看提示。
ECHO.
ECHO 如果盘符是 C 的 WIN7 系统,需手动替换注册表键值。
ECHO.
ECHO 当前登录用户目录:%HOMEPATH% 。
ECHO.
ECHO 自动备份到 %wimpath% 目录 。
ECHO.
ECHO 选择 1 :全新安装系统盘是 X 盘符的硬盘系统 。
ECHO.
ECHO 选择 2 :在当前系统下安装 WIM 驱动和热备份 。
ECHO.
ECHO 选择 N 退出 。
ECHO.
ECHO qiqiqicool@2013.11.08
ECHO ---------------------------------------------------------
set cho=N
SET /P cho= 请输入你的选择...
if /I "%cho%"=="1" goto SETUP
if /I "%cho%"=="2" goto UPRAM
goto :eof
:SETUP
set wimpath=C:
ECHO ---------------------------------------------------------
ECHO.
ECHO 全新安装系统盘是 X 盘符的硬盘系统 。
ECHO 以方便制作 WIM 镜像的内存系统 。
ECHO 请解压 WIN7 安装文件到 %wimpath% 目录中 。
ECHO WIN7 安装文件只需要 Program Files、
ECHO ProgramData、Users、WINDOWS 四个目录 。
ECHO 操作完毕,重启进行全新安装 X 的硬盘系统前,
ECHO 请确保以上四个目录拷贝到当前系统 C:\ 。
ECHO 系统原有的 C 盘启动的 WIN7 BCD 菜单不用修改。
ECHO.
ECHO ---------------------------------------------------------
SET /P wimpath= 请指定 WIN7 安装文件路径,直接回车为 %wimpath%\ 。
for %%i in (Windows\system32\config\system) do if not exist %wimpath%\%%i echo 注册表文件未找到。 &goto SETUP
reg LOAD HKLM\1sys %wimpath%\Windows\system32\config\system
reg COPY HKLM\SYSTEM\MountedDevices HKLM\1sys\MountedDevices /s /f
for /f "tokens=3" %%D in ('REG QUERY HKLM\1sys\MountedDevices /v \DosDevices\C:') do (REG add HKLM\1sys\MountedDevices /v \DosDevices\X: /t REG_BINARY /d %%D /f)
reg delete HKLM\1sys\MountedDevices /f /v \DosDevices\C:
reg unload HKLM\1sys
goto end
:UPRAM
if not exist %wimpath% md %wimpath%
set cho=Y
SET /P cho= 是否热备份系统文件? ( N 为跳过 )
if /I "%cho%"=="n" goto regcopy
ECHO 拷贝 Users 下系统文件...
robocopy "%Systemdrive%\Users" "%wimpath%\Users" /E /ZB /COPYALL /PURGE /XD Default History Recent temp Temporary* UserData /XF *.hlp *.log thumbcache*.* IconCache.db Thumbs.db NTUSER.* UsrClass.* /XJ /R:2 /W:5 /NP /log:copylog.txt /TEE
ECHO 拷贝 WINDOWS 下系统文件...
robocopy "%SystemRoot%" "%wimpath%\WINDOWS" /S /ZB /COPYALL /PURGE /XD Boot CatRoot2 CSC config Help LogFiles prefetch temp /XF 7B296FB0-* NTUSER.* *.hlp *.log *.pnf bootstat.dat Thumbs.db /R:2 /W:5 /NP /log+:copylog.txt /TEE
ECHO 拷贝 Program Files 下系统文件...
robocopy "%Systemdrive%\Program Files" "%wimpath%\Program Files" /E /ZB /COPYALL /PURGE /XF *.hlp *.log Thumbs.db /R:2 /W:5 /NP /log+:copylog.txt /TEE
ECHO ProgramData 下系统文件...
robocopy "%Systemdrive%\ProgramData" "%wimpath%\ProgramData" /E /ZB /COPYALL /PURGE /XF *.hlp *.log Thumbs.db /R:2 /W:5 /NP /log+:copylog.txt /TEE
ECHO.
ECHO 拷贝系统文件完毕。
ECHO.
:regcopy
set cho=Y
SET /P cho= 是否热备份注册表? ( N 为跳过 )
if /I "%cho%"=="n" goto wimsetup
rd /s /q %wimpath%\Temp >nul 2>nul
md %wimpath%\Temp
reg SAVE HKLM\system %wimpath%\Temp\system /y
reg UNLOAD HKLM\1sys >nul 2>nul
reg LOAD HKLM\1sys %wimpath%\Temp\system
reg add "HKLM\1sys\ControlSet001\Control\Session Manager\Memory Management" /f /v "PagingFiles" /t REG_SZ /d "" >nul
reg delete "HKLM\1sys\MountedDevices" /f /v "\DosDevices\X:"
setacl -on MACHINE\1sys\ControlSet002 -ot reg -actn setowner -ownr "n:Administrators" -actn rstchldrn -rst "dacl" -rec cont_obj -silent
reg delete "HKLM\1sys\ControlSet002" /f
if not exist %wimpath%\Windows\System32\config md %wimpath%\Windows\System32\config
copy %SystemRoot%\System32\config\COMPONENTS %wimpath%\Windows\System32\config
Reg save HKLM\1sys %wimpath%\WINDOWS\system32\config\SYSTEM /y
Reg save HKLM\software %wimpath%\WINDOWS\system32\config\SOFTWARE /y
Reg save HKLM\SAM %wimpath%\WINDOWS\system32\config\SAM /y
Reg save HKLM\SECURITY %wimpath%\WINDOWS\system32\config\SECURITY /y
Reg save HKU\.DEFAULT %wimpath%\WINDOWS\system32\config\DEFAULT /y
Reg save HKCU %wimpath%%HOMEPATH%\NTUSER.DAT /y
Reg save HKCU\software\classes %wimpath%%HOMEPATH%\AppData\Local\Microsoft\Windows\UsrClass.dat /y
Reg save HKU\S-1-5-19 %wimpath%\Windows\ServiceProfiles\LocalService\NTUSER.DAT /y
Reg save HKU\S-1-5-20 %wimpath%\Windows\ServiceProfiles\NetworkService\NTUSER.DAT /y
reg UNLOAD HKLM\1sys >nul 2>nul
rd /s /q %wimpath%\Temp >nul 2>nul
ECHO.
ECHO 热备份注册表完毕。
ECHO.
type copylog.txt|find "ERROR" /i|find "New File" /i /v|find "New Dir" /i /v>error.txt
echo 以上是不能拷贝的文件,自己根据情况在打包前补齐。 >>error.txt
start error.txt
:wimsetup
if not exist %SystemDrive%\boot\BCD goto wimcap
set wimname=%SystemDrive%\boot\QiRAMW7.wim
ECHO ---------------------------------------------------------
ECHO.
ECHO 安装 WIM 启动驱动...
ECHO.
ECHO ---------------------------------------------------------
for %%i in (fbwf.sys ramdisk.sys wimfsf.sys) do if not exist %wimpath%\Windows\system32\drivers\%%i copy %%i %wimpath%\Windows\system32\drivers\%%i
copy fbwf.cfg %wimpath%\Windows
for %%i in (Windows\system32\config\system) do if not exist %wimpath%\%%i echo 注册表文件未找到。 &pause &exit
reg LOAD HKLM\1sys %wimpath%\Windows\system32\config\system
reg add "HKEY_CURRENT_USER\Software\Sysinternals\PsExec" /f /v "EulaAccepted" /t REG_DWORD /d 1
psexec -i -s -d %~dp0wimsetup.bat
reg delete "HKEY_CURRENT_USER\Software\Sysinternals" /f
reg add "HKLM\1sys\Setup" /f /v "SystemPartition" /t REG_SZ /d "\Device\Ramdisk{d9b257fc-684e-4dcb-ab79-03cfa2f6b750}"
reg add "HKLM\1sys\ControlSet001\Control" /f /v "SystemBootDevice" /t REG_SZ /d "ramdisk(0)"
reg add "HKLM\1sys\ControlSet001\Control\Session Manager\Memory Management" /f /v "DisablePagingExecutive" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Control\Session Manager\Memory Management" /f /v "LargeSystemCache" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Control\Session Manager\Memory Management" /f /v "PagedPoolSize" /t REG_DWORD /d 4294967295
reg add "HKLM\1sys\ControlSet001\Control\Session Manager\Memory Management" /f /v "SystemPages" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Control\GroupOrderList" /f /v "FSFilter Compression" /t REG_BINARY /d 0100000001000000
reg add "HKLM\1sys\ControlSet001\Control\GroupOrderList" /f /v "FSFilter System Recovery" /t REG_BINARY /d 0100000001000000
reg add "HKLM\1sys\ControlSet001\Control\GroupOrderList" /f /v "FSFilter Infrastructure" /t REG_BINARY /d 0100000001000000
reg add "HKLM\1sys\ControlSet001\Control\CrashControl" /f /v "AutoReboot" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Control\CrashControl" /f /v "CrashDumpEnabled" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Control\CrashControl" /f /v "LogEvent" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Control\CrashControl" /f /v "SendAlert" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Control\Class\{9D6D66A6-0B0C-4563-9077-A0E9A7955AE4}" /f /v "Class" /t REG_SZ /d "Ramdisk"
reg add "HKLM\1sys\ControlSet001\Control\Class\{9D6D66A6-0B0C-4563-9077-A0E9A7955AE4}" /f /v "Icon" /t REG_SZ /d "-5"
reg add "HKLM\1sys\ControlSet001\Control\Class\{9D6D66A6-0B0C-4563-9077-A0E9A7955AE4}" /f /ve /t REG_SZ /d "Ramdisk"
reg add "HKLM\1sys\ControlSet001\Services\Ramdisk" /f /v "Type" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\Ramdisk" /f /v "Start" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Services\Ramdisk" /f /v "ErrorControl" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\Ramdisk" /f /v "ImagePath" /t REG_EXPAND_SZ /d "system32\DRIVERS\ramdisk.sys"
reg add "HKLM\1sys\ControlSet001\Services\Ramdisk" /f /v "DisplayName" /t REG_SZ /d "Windows RAM 磁盘驱动程序"
reg add "HKLM\1sys\ControlSet001\Services\Ramdisk\Debug" /f /v "DebugComponents" /t REG_DWORD /d 2147483647
reg add "HKLM\1sys\ControlSet001\Services\Ramdisk\Debug" /f /v "DebugLevel" /t REG_DWORD /d 5
reg add "HKLM\1sys\ControlSet001\Services\Ramdisk\Security" /f /v "Security" /t REG_BINARY /d 01001480b8000000c4000000140000003000000002001c000100000002801400ff010f00010100000000000100000000020088000600000000001400fd01020001010000000000051200000000001800ff010f0001020000000000052000000020020000000014008d010200010100000000000504000000000014008d010200010100000000000506000000000014000001000001010000000000050b00000000001800fd01020001020000000000052000000023020000010100000000000512000000010100000000000512000000
reg add "HKLM\1sys\ControlSet001\Services\FBWF" /f /v "DependOnService" /t REG_MULTI_SZ /d "FltMgr"
reg add "HKLM\1sys\ControlSet001\Services\FBWF" /f /v "Description" /t REG_SZ /d "File Based Write Filter driver"
reg add "HKLM\1sys\ControlSet001\Services\FBWF" /f /v "DisplayName" /t REG_SZ /d "File Based Write Filter"
reg add "HKLM\1sys\ControlSet001\Services\FBWF" /f /v "EnabledOnAllSkus" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Services\FBWF" /f /v "Group" /t REG_SZ /d "FSFilter SYSTEM Recovery"
reg add "HKLM\1sys\ControlSet001\Services\FBWF" /f /v "ImagePath" /t REG_EXPAND_SZ /d "system32\drivers\Fbwf.sys"
reg add "HKLM\1sys\ControlSet001\Services\FBWF" /f /v "Start" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Services\FBWF" /f /v "Type" /t REG_DWORD /d 2
reg add "HKLM\1sys\ControlSet001\Services\FBWF\Enum" /f /v "0" /t REG_SZ /d "Root\LEGACY_FBWF\0000"
reg add "HKLM\1sys\ControlSet001\Services\FBWF\Enum" /f /v "Count" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\FBWF\Enum" /f /v "NextInstance" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\FBWF\Instances" /f /v "DefaultInstance" /t REG_SZ /d "Fbwf Instance"
reg add "HKLM\1sys\ControlSet001\Services\FBWF\Instances\Fbwf Instance" /f /v "Altitude" /t REG_SZ /d "226000"
reg add "HKLM\1sys\ControlSet001\Services\FBWF\Instances\Fbwf Instance" /f /v "Flags" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "AttachWhenLoaded" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "Description" /t REG_SZ /d "File SYSTEM Filter manager Driver"
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "DisplayName" /t REG_SZ /d "FltMgr"
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "ErrorControl" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "Group" /t REG_SZ /d "FSFilter Infrastructure"
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "ImagePath" /t REG_EXPAND_SZ /d "system32\drivers\fltmgr.sys"
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "Start" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "Tag" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\FltMgr" /f /v "Type" /t REG_DWORD /d 2
reg add "HKLM\1sys\ControlSet001\Services\FltMgr\Enum" /f /v "0" /t REG_SZ /d "Root\LEGACY_FLTMGR\0000"
reg add "HKLM\1sys\ControlSet001\Services\FltMgr\Enum" /f /v "Count" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\FltMgr\Enum" /f /v "NextInstance" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\WimFsf" /f /v "DisplayName" /t REG_SZ /d "Windows Imaging File System Filter Driver"
reg add "HKLM\1sys\ControlSet001\Services\WimFsf" /f /v "Group" /t REG_SZ /d "FSFilter Compression"
reg add "HKLM\1sys\ControlSet001\Services\WimFsf" /f /v "ErrorControl" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\WimFsf" /f /v "Start" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Services\WimFsf" /f /v "Type" /t REG_DWORD /d 2
reg add "HKLM\1sys\ControlSet001\Services\WimFsf" /f /v "ImagePath" /t REG_EXPAND_SZ /d "system32\DRIVERS\wimfsf.sys"
reg add "HKLM\1sys\ControlSet001\Services\WimFsf" /f /v "DependOnService" /t REG_MULTI_SZ /d "fltmgr"
reg add "HKLM\1sys\ControlSet001\Services\WimFsf\Instances" /f /v "DefaultInstance" /t REG_SZ /d "Wimfsf Instance"
reg add "HKLM\1sys\ControlSet001\Services\WimFsf\Instances\Wimfsf Instance" /f /v "Altitude" /t REG_SZ /d "161000"
reg add "HKLM\1sys\ControlSet001\Services\WimFsf\Instances\Wimfsf Instance" /f /v "Flags" /t REG_DWORD /d 0
reg add "HKLM\1sys\ControlSet001\Services\WimFsf\Enum" /f /v "0" /t REG_SZ /d "Root\LEGACY_WIMFSF\0000"
reg add "HKLM\1sys\ControlSet001\Services\WimFsf\Enum" /f /v "Count" /t REG_DWORD /d 1
reg add "HKLM\1sys\ControlSet001\Services\WimFsf\Enum" /f /v "NextInstance" /t REG_DWORD /d 1
reg delete "HKLM\1sys\MountedDevices" /f
reg delete "HKLM\1sys\ControlSet001\services\PEAUTH" /f >nul 2>nul
if /I %SystemDrive% == X: goto editbcd
rem rd /s /q %wimpath%\WINDOWS\ServiceProfiles
rem copy /y DEFAULT %wimpath%\Windows\system32\config\
for %%i in (Windows\system32\config\SOFTWARE %HOMEPATH%\NTUSER.DAT %HOMEPATH%\AppData\Local\Microsoft\Windows\UsrClass.dat) do if not exist %wimpath%\%%i echo 注册表文件未找到。 &pause &exit
reg LOAD HKLM\4ucs %wimpath%%HOMEPATH%\AppData\Local\Microsoft\Windows\UsrClass.dat
reg delete "HKLM\4ucs\Local Settings\MuiCache\1\AAF68885" /f
reg UNLOAD HKLM\4ucs
reg LOAD HKLM\2sof %wimpath%\Windows\system32\config\SOFTWARE
reg LOAD HKLM\3usr %wimpath%%HOMEPATH%\NTUSER.DAT
ECHO ---------------------------------------------------------
ECHO.
ECHO 文件、注册表权限设置,请等待...
ECHO.
ECHO ---------------------------------------------------------
setacl -on %wimpath% -ot file -actn setowner -ownr "n:Administrators"
setacl -on %wimpath% -ot file -actn setprot -op "dacl:p_c;sacl:p_c"
setacl -on %wimpath% -ot file -actn clear -clr "dacl,sacl"
setacl -on %wimpath% -ot file -actn ace -ace "n:Everyone;p:full"
setacl -on MACHINE\1sys -ot reg -actn setowner -ownr "n:Administrators" -actn rstchldrn -rst "dacl,sacl" -rec cont_obj -silent
setacl -on MACHINE\1sys -ot reg -actn setprot -op "dacl:p_c;sacl:p_c" -actn clear -clr "dacl,sacl"
setacl -on MACHINE\1sys -ot reg -actn ace -ace "n:Everyone;p:full"
setacl -on MACHINE\2sof -ot reg -actn setowner -ownr "n:Administrators" -actn rstchldrn -rst "dacl" -rec cont_obj -silent
setacl -on MACHINE\2sof -ot reg -actn setprot -op "dacl:p_c;sacl:p_c" -actn clear -clr "dacl,sacl"
setacl -on MACHINE\2sof -ot reg -actn ace -ace "n:Everyone;p:full"
ECHO ---------------------------------------------------------
ECHO.
ECHO 当前系统盘符不是 X,要手动批量替换加载的配置单元:
ECHO.
ECHO HKLM\1sys、HKLM\2sof、HKLM\3usr 中键值 C:为 X:
ECHO.
ECHO 注册表键值替换完毕后,手动关闭 Registry Workshop 。
ECHO.
ECHO ---------------------------------------------------------
start /wait regedt
reg UNLOAD HKLM\2sof
reg UNLOAD HKLM\3usr
:editbcd
reg UNLOAD HKLM\1sys
del %wimpath%\Windows\System32\config\*.* /ah /q
ECHO ---------------------------------------------------------
ECHO.
ECHO 建立 QiRAMW7 开机 BCD 菜单启动项...
ECHO.
ECHO 默认修改 %SystemDrive%\boot\BCD
ECHO.
ECHO ---------------------------------------------------------
copy /y boot.sdi %SystemDrive%\boot\
set cho=Y
SET /P cho= 是否建立 QiRAMW7 启动项? ( N 为跳过 )
if /I "%cho%"=="n" goto wimcap
set bcddir=/store %SystemDrive%\boot\BCD
bcdedit %bcddir% /create {ramdiskoptions} /d "Ramdisk options"
bcdedit %bcddir% /set {ramdiskoptions} ramdisksdidevice "boot"
bcdedit %bcddir% /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
for /f "delims={,} tokens=2" %%a in ('bcdedit %bcddir% -create /d "QiRAMW7" -application osloader ') do set ID={%%a}
bcdedit %bcddir% -set %ID% device ramdisk="[boot]\boot\QiRAMW7.wim,{ramdiskoptions}"
bcdedit %bcddir% -set %ID% osdevice ramdisk="[boot]\boot\QiRAMW7.wim,{ramdiskoptions}"
bcdedit %bcddir% -set %ID% path \windows\system32\winload.exe
bcdedit %bcddir% -set %ID% locale zh-CN
bcdedit %bcddir% -set %ID% systemroot \windows
bcdedit %bcddir% -set %ID% detecthal no
bcdedit %bcddir% -set %ID% winpe yes
bcdedit %bcddir% -set %ID% testsigning yes
bcdedit %bcddir% -set %ID% nointegritychecks yes
bcdedit %bcddir% -set %ID% pae forceenable
bcdedit %bcddir% -displayorder %ID% -addlast
:wimcap
ECHO ---------------------------------------------------------
ECHO.
ECHO 自动打包 %wimpath% 下文件为 %wimname%...
ECHO.
ECHO ---------------------------------------------------------
set cho=Y
SET /P cho= 是否自动打包系统? ( N 为跳过 )
if /I "%cho%"=="n" goto end
if not exist %wimname% goto capt
set cho=Y
SET /P cho= 直接回车为覆盖方式,其他输入为追加方式。
if /I "%cho%"=="Y" goto capt
imagex /boot /append %wimpath%\ %wimname% "%date%_%time%"
goto defrag
:capt
imagex /capture %wimpath%\ %wimname% "QiRAMW7" /boot /compress maximum
:defrag
set ram=0
for /f "tokens=3 delims=, " %%i in ('dir %wimname% /s/a-d ^|find/v " 0"' ) do set ram=%%i
if /I %ram% lss 50 echo QiRAMW7.wim文件大于1G,RAMOS系统可能不能启动。 & pause & goto end
set cho=Y
SET /P cho= 是否要整理镜像文件? ( N 为跳过 )
if /I "%cho%"=="N" goto end
ECHO ---------------------------------------------------------
ECHO.
ECHO 正在整理镜像文件,请等待...
ECHO.
ECHO ---------------------------------------------------------
copy %wimname% %wimname%.bk && del %wimname% >nul
move %wimname%.bk %wimname%
:end
ECHO.
ECHO.
echo ㄧ○︿
echo \
echo √ ﹀
ECHO.
ECHO.
echo 处理完毕。重启后,体验RAMOS的魅力吧!
pause>nul
exit
|
|