加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Make_Winxshell_MiniX64.bat 13.76 KB
一键复制 编辑 原始数据 按行查看 历史
江南一根葱 提交于 2021-05-15 23:09 . add default
@echo off
cd /d %~dp0
title WindowsPE -- 2009
set /p cddir=输入虚拟光驱盘符:
if /i "%cddir%"=="" (echo 没有输入数据&&pause&&exit) else (goto nextplay)
:::for /f %%a in ('dir /b %~dp0cn_w*.iso') do set iso=%%a
::set wimfile=boot.wim
::set arch=x64
::echo 正在挂载%iso%为B盘...
::start "" /w /min %NSudo% -U:S -P:E -M:S "%~dp0bin\mount_%arch%.exe %iso% B:"
::if exist B:\ echo 已挂载B盘,先卸载&&start "" /w imdisk -d -m B:
::echo 挂载B盘...
::start "" /w imdisk -a -o cd -f %iso% -m B:
:::echo 复制%wimfile%到当前目录...
::copy /y B:\sources\boot.wim %~dp0
::bin\7z.exe e -o"%~dp0" -aoa "B:\sources\install.wim" 1/Windows/System32/Recovery/winre.wim >NUL
:nextplay
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole cmd /c rd /s /Q "%~dp0data\winpe"
md "%~dp0data\winpe"
set wimdir=%cddir%:\sources\install.wim
set bootdir=%cddir%:\sources\boot.wim
:::set bootdir=%~dp0boot.wim
set /p inwiminfo=输入install分卷号:
if /i "%inwiminfo%"=="" (echo 没有输入数据&&pause&&exit) else (goto peplay)
:peplay
echo 提取WINPE相关文件
:::"%~dp0data\tools\wimlib-imagex.exe" extract "%wimdir%" %inwiminfo% @"%~dp0data\files\install.txt" --dest-dir="%~dp0data\winpe" --nullglob
for /f %%a in ('dir /ad /b %~dp0data\winpe\Windows\System32\DriverStore\FileRepository') do (echo %%a >>%~dp0data\temp\pe-drv.txt)
::"%~dp0data\tools\wimlib-imagex.exe" extract "%bootdir%" 1 --dest-dir="%~dp0data\winpe" --nullglob
"%~dp0data\tools\wimlib-imagex.exe" extract "%bootdir%" 1 @"%~dp0data\files\boot.txt" --dest-dir="%~dp0data\winpe" --nullglob
"%~dp0data\tools\wimlib-imagex.exe" extract "%wimdir%" %inwiminfo% \Windows\System32\config\software --dest-dir="%~dp0data\temp\config" --nullglob
"%~dp0data\tools\wimlib-imagex.exe" extract "%wimdir%" %inwiminfo% \Windows\System32\config\system --dest-dir="%~dp0data\temp\config" --nullglob
"%~dp0data\tools\wimlib-imagex.exe" extract "%wimdir%" %inwiminfo% \Windows\System32\config\DRIVERS --dest-dir="%~dp0data\temp\config" --nullglob
echo 挂载注册表配置单元
reg load hklm\os-drv "%~dp0data\temp\config\DRIVERS"
reg load hklm\os-soft "%~dp0data\temp\config\software"
reg load hklm\os-sys "%~dp0data\temp\config\system"
reg load hklm\pe-def "%~dp0data\winpe\windows\system32\config\default"
reg load hklm\pe-soft "%~dp0data\winpe\windows\system32\config\software"
reg load hklm\pe-sys "%~dp0data\winpe\windows\system32\config\system"
reg load hklm\pe-drv "%~dp0data\winpe\windows\system32\config\DRIVERS"
echo 导入注册表
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg import "%~dp0data\reg\pe-drv.reg"
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg import "%~dp0data\reg\pe-lite.reg"
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg import "%~dp0data\reg\pe-def.reg"
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg import "%~dp0data\reg\pe-sys-winxshell.reg"
echo 获取software注册表权限
"%~dp0data\tools\setacl.exe" -on "hklm\pe-soft" -ot reg -actn setowner -ownr "n:Everyone" -rec yes -silent
if not errorlevel 1 echo software...
"%~dp0data\tools\setacl.exe" -on "hklm\pe-soft" -ot reg -actn ace -ace "n:Everyone;p:full;m:grant;i:so,sc" -op DACL:p_c -rec yes -silent
if not errorlevel 1 echo software...ok
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg import "%~dp0data\reg\pe-lite.reg"
echo 复制必要的software注册表到PE
for /f "tokens=*" %%e in (%~dp0data\reg\pe-soft-default.txt) do (
echo %%e
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg copy "hklm\os-soft\%%e" "hklm\pe-soft\%%e" /S /F
)
for /f "tokens=*" %%t in (%~dp0data\reg\pe+soft-default.txt) do (
echo %%t
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg copy "hklm\os-soft\%%t" "hklm\pe-soft\%%t" /F
)
echo 复制必要的system注册表到PE
for /f "tokens=*" %%c in (%~dp0data\reg\pe-sys.txt) do (
echo %%c
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg copy "hklm\os-sys\%%c" "hklm\pe-sys\%%c" /S /F
)
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg import "%~dp0data\reg\pe-soft-winxshell.reg"
echo 复制必要的DRIVERS注册表到PE
for /f "tokens=*" %%h in (%~dp0data\reg\pe-drv.txt) do (
echo %%h
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg copy "hklm\os-drv\%%h" "hklm\pe-drv\%%h" /S /F
)
for /f "tokens=*" %%j in (%~dp0data\temp\pe-drv.txt) do (
echo %%j
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg copy "hklm\os-drv\DriverDatabase\DriverPackages\%%j" "hklm\pe-drv\DriverDatabase\DriverPackages\%%j" /S /F
)
echo 替换c/d为x,删除Interactive User
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole regfind -p HKEY_LOCAL_MACHINE\pe-soft -y C:\ -y -r X:\
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole regfind -p HKEY_LOCAL_MACHINE\pe-soft -y D:\ -y -r X:\
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole regfind -p HKEY_LOCAL_MACHINE\pe-soft\Classes\AppID -y Interactive User -r
echo 写入imdisk注册表
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\*\shell\ImDiskMountFile" /ve /t REG_SZ /d "装载为 ImDisk 虚拟磁盘" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\*\shell\ImDiskMountFile" /v "Icon" /t REG_SZ /d "imdisk.cpl,0" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\*\shell\ImDiskMountFile\command" /ve /t REG_SZ /d "rundll32.exe imdisk.cpl,RunDLL_MountFile %%L" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\Drive\shell\ImDiskSaveImage" /ve /t REG_SZ /d "将磁盘内容保存为映像文件" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\Drive\shell\ImDiskSaveImage" /v "Icon" /t REG_SZ /d "imdisk.cpl,0" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\Drive\shell\ImDiskSaveImage\command" /ve /t REG_SZ /d "rundll32.exe imdisk.cpl,RunDLL_SaveImageFile %%L" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\Drive\shell\ImDiskUnmount" /ve /t REG_SZ /d "卸载 ImDisk 虚拟磁盘" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\Drive\shell\ImDiskUnmount" /v "Icon" /t REG_SZ /d "imdisk.cpl,0" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SOFT\Classes\Drive\shell\ImDiskUnmount\command" /ve /t REG_SZ /d "rundll32.exe imdisk.cpl,RunDLL_RemoveDevice %%L" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\AWEAlloc" /v "Type" /t REG_DWORD /d "1" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\AWEAlloc" /v "Start" /t REG_DWORD /d "2" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\AWEAlloc" /v "ErrorControl" /t REG_DWORD /d "0" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\AWEAlloc" /v "ImagePath" /t REG_EXPAND_SZ /d "\SystemRoot\system32\DRIVERS\awealloc.sys" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\AWEAlloc" /v "DisplayName" /t REG_SZ /d "AWE Memory Allocation Driver" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\AWEAlloc" /v "Description" /t REG_SZ /d "Driver for physical memory allocation through AWE" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDisk" /v "Type" /t REG_DWORD /d "1" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDisk" /v "Start" /t REG_DWORD /d "2" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDisk" /v "ErrorControl" /t REG_DWORD /d "0" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDisk" /v "ImagePath" /t REG_EXPAND_SZ /d "\SystemRoot\system32\DRIVERS\imdisk.sys" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDisk" /v "DisplayName" /t REG_SZ /d "ImDisk Virtual Disk Driver" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDisk" /v "Description" /t REG_SZ /d "Disk emulation driver" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDskSvc" /v "Type" /t REG_DWORD /d "16" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDskSvc" /v "Start" /t REG_DWORD /d "2" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDskSvc" /v "ErrorControl" /t REG_DWORD /d "0" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDskSvc" /v "ImagePath" /t REG_EXPAND_SZ /d "X:\windows\system32\imdsksvc.exe" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDskSvc" /v "DisplayName" /t REG_SZ /d "ImDisk Virtual Disk Driver Helper" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDskSvc" /v "ObjectName" /t REG_SZ /d "LocalSystem" /f
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add "HKLM\PE-SYS\ControlSet001\Services\ImDskSvc" /v "Description" /t REG_SZ /d "Helper service for ImDisk Virtual Disk Driver." /f
echo 删除资源管理器左侧网络
"%~dp0data\tools\NSudo.exe" -U:T -P:E -Wait -UseCurrentConsole reg add hklm\pe-soft\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder /v Attributes /t REG_DWORD /d 0xb0940064 /F
echo 卸载注册表配置单元
reg unload hklm\os-drv
reg unload hklm\pe-drv
reg unload hklm\os-soft
reg unload hklm\os-sys
reg unload hklm\pe-soft
reg unload hklm\pe-sys
reg unload hklm\pe-def
echo 获取WINPE文件夹所有权
takeown /f "%~dp0data\winpe" /r /d y
cacls "%~dp0data\winpe" /T /E /G Everyone:F
echo 压缩注册表配置单元
"%~dp0data\tools\ru.exe" -accepteula -h "%~dp0data\winpe\Windows\System32\config\DRIVERS" hklm\drv
"%~dp0data\tools\ru.exe" -accepteula -h "%~dp0data\winpe\Windows\System32\config\SOFTWARE" hklm\soft
"%~dp0data\tools\ru.exe" -accepteula -h "%~dp0data\winpe\Windows\System32\config\SYSTEM" hklm\sys
echo 破解USB弹出功能文件
%~dp0data\tools\binmay -u "%~dp0data\winpe\Windows\System32\DeviceSetupManager.dll" -s u:SystemSetupInProgress -r u:DisableDeviceSetupMgr
echo 删除dll备份文件
del "%~dp0data\winpe\Windows\System32\DeviceSetupManager.dll.org"
echo 删除多余的注册表临时文件
del /f /q /ah "%~dp0data\winpe\Windows\System32\config\*.*"
echo 解压WINPE预配置文件
"%~dp0data\tools\7z.exe" x "%~dp0data\tools\LitePE_winxshell.dll" -y -o"%~dp0data\winpe"
echo 解压ISO镜像文件,为制作ISO镜像做准备
"%~dp0data\tools\7z.exe" x "%bootdir%" -y -o"%~dp0data\temp" 2\windows\boot
xcopy "%~dp0data\temp\2\windows\boot\pcat\bootmgr" "%~dp0data\temp\iso\" /F /Y /S /H /R
xcopy "%~dp0data\temp\2\windows\boot\dvd\efi\bcd" "%~dp0data\temp\iso\efi\microsoft\boot\" /F /Y /S /H /R
xcopy "%~dp0data\temp\2\windows\boot\dvd\efi\boot.sdi" "%~dp0data\temp\iso\boot\" /F /Y /S /H /R
xcopy "%~dp0data\temp\2\windows\boot\dvd\pcat\bcd" "%~dp0data\temp\iso\boot\" /F /Y /S /H /R
echo f|xcopy "%~dp0data\temp\2\windows\boot\efi\bootmgfw.efi" "%~dp0data\temp\iso\efi\boot\bootx64.efi" /F /Y /S /H /R
xcopy "%~dp0data\temp\2\windows\boot\dvd\efi\en-US\efisys_noprompt.bin" "%~dp0data\temp\" /F /Y /S /H /R
xcopy "%~dp0data\temp\2\windows\boot\dvd\pcat\etfsboot.com" "%~dp0data\temp\" /F /Y /S /H /R
xcopy "%~dp0data\temp\2\windows\boot\efi\bootmgr.efi" "%~dp0data\temp\iso\" /F /Y /S /H /R
md "%~dp0data\temp\iso\sources"
echo 打包%~dp0data\winpe文件夹到%~dp0data\temp\iso\sources\boot.wim
"%~dp0data\tools\wimlib-imagex.exe" capture "%~dp0data\winpe" "%~dp0data\temp\iso\sources\boot.wim" "WindowsPE" --boot --compress=lzx --rebuild
::增删文件
set bootwim=%~dp0data\temp\iso\sources\boot.wim
echo. & echo 开始时间:%time% & set startT=%time%
echo. & echo 稍候………………
if exist excel.txt del excel.txt /f /q
for /f "delims=" %%i in (bin\Win10x86_64.txt) do (
echo %%i | find ".exe" >NUL && (
for /f "delims=" %%a in ('bin\wimlib dir %bootwim% 1 ^| find "." ^| findstr /vil "%%i"') do echo delete --force --recursive "%%a">>excel.txt
) || (
for /f "delims=" %%a in ('bin\wimlib dir %bootwim% 1 --path=windows\winsxs ^| find "." ^| findstr /vi "%%i"') do echo delete --force --recursive "%%a">>excel.txt
)
)
echo. & echo 正在增删削减%bootwim%包里的文件制作PE过程中,请您稍微等待 ...... & echo.
bin\wimlib dir %bootwim% 1 --path=Windows\SysWOW64 | find ".exe" >NUL && (set FD=x64) || (set FD=x86)
bin\wimlib update %bootwim%<%FD%\add2wimnewbee.txt>NUL
bin\wimlib update %bootwim% delete --force --recursive \Windows\SysWOW64
bin\wimlib update %bootwim% -command="delete --force \Windows\explorer.exe"
bin\wimlib update %bootwim% -command="delete --force \Windows\pecmd.ini"
bin\wimlib optimize %bootwim%
copy /y %bootwim% %~dp0minix64.wim
echo. & echo 制作完成 & echo.
:::制作完成
echo 打包windowspe.iso
"%~dp0data\tools\oscdimg.exe" -h -d -m -o -u1 -lWindowsPE -bootdata:2#p00,e,b%~dp0data\temp\etfsboot.com#pEF,e,b%~dp0data\temp\efisys_noprompt.bin %~dp0data\temp\iso %~dp0WindowsPE.iso
echo 删除临时目录%~dp0data\temp
rd /s /Q "%~dp0data\temp"
echo 建立临时目录%~dp0data\temp
md "%~dp0data\temp"
echo 重置变量
set wimdir=
set wiminfo=
set inwiminfo=
set bootdir=
pause
exit
@echo 卸载B盘.....
start "" /w imdisk -d -m B
EXIT
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化