mirror of
https://github.com/dragonflylee/WimHelper.git
synced 2025-01-08 11:37:37 +08:00
115 lines
3.7 KiB
Batchfile
115 lines
3.7 KiB
Batchfile
|
@echo off
|
|||
|
|
|||
|
rem <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ԱȨ<D4B1><C8A8>
|
|||
|
pushd "%~dp0" && Dism 1>nul 2>nul || mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 "%*"","","runas",1)(window.close) && Exit /B 1
|
|||
|
rem <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
color 1F
|
|||
|
mode con cols=120
|
|||
|
cls
|
|||
|
setlocal EnableDelayedExpansion
|
|||
|
set NSudo="%~dp0Bin\%PROCESSOR_ARCHITECTURE%\NSudo.exe"
|
|||
|
set "Dism=Dism.exe /NoRestart /LogLevel:1"
|
|||
|
set "ImageLanguage=zh-CN"
|
|||
|
set "Mount=%~1"
|
|||
|
|
|||
|
rem ѡ<><D1A1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
if "%Mount%" equ "" call :SelectFolder
|
|||
|
if "%Mount%" equ "" goto :Exit
|
|||
|
|
|||
|
for %%i in (
|
|||
|
QuickAssist
|
|||
|
OpenSSH.Client
|
|||
|
) do call :RemoveCapability "%Mount%" "%%i"
|
|||
|
|
|||
|
for %%i in (
|
|||
|
HyperV-Guest-Networking-SrIov-onecore-Package
|
|||
|
Microsoft-Hyper-V-ClientEdition-Package
|
|||
|
Microsoft-Windows-HyperV-Guest-Package
|
|||
|
Microsoft-Windows-HyperV-Guest-WOW64-Package
|
|||
|
HyperV-Compute-System-VmDirect-Package
|
|||
|
HyperV-Feature-ApplicationGuard-Package
|
|||
|
Microsoft-Hyper-V-Hypervisor-Package
|
|||
|
Microsoft-Windows-PAW-Feature-Package
|
|||
|
HyperV-VID-Package
|
|||
|
Microsoft-Windows-HyperV-HypervisorPlatform-Package
|
|||
|
Microsoft-Windows-HyperV-OptionalFeature-HypervisorPlatform-Package
|
|||
|
Microsoft-Windows-OneCore-Containers-Opt-Package
|
|||
|
) do call :RemoveComponent "%Mount%" "%%i"
|
|||
|
|
|||
|
call :ImportRegistry "%CD%\O.reg" "%Mount%"
|
|||
|
|
|||
|
pause
|
|||
|
goto :Exit
|
|||
|
|
|||
|
:SelectFolder
|
|||
|
set folder=mshta "javascript:var folder=new ActiveXObject('Shell.Application').BrowseForFolder(0,'ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼', 513, '');if(folder) new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(folder.Self.Path);window.close();"
|
|||
|
for /f %%f in ('%folder%') do set "Mount=%%f"
|
|||
|
goto :eof
|
|||
|
|
|||
|
rem <20>Ƴ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD> [ %~1 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>, %~2 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ]
|
|||
|
:RemoveCapability
|
|||
|
for /f "tokens=4" %%f in ('%Dism% /English /Image:"%~1" /Get-Capabilities ^| findstr Capability ^| findstr /i "%~2"') do (
|
|||
|
echo.<2E>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD> [%%f]
|
|||
|
%Dism% /Image:"%~1" /Remove-Capability /CapabilityName:"%%f" /Quiet
|
|||
|
)
|
|||
|
goto :eof
|
|||
|
|
|||
|
rem <20>Ƴ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD> [ %~1 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>, %~2 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ]
|
|||
|
:RemoveComponent
|
|||
|
setlocal
|
|||
|
rem <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
call :MountImageRegistry "%~1"
|
|||
|
for /f "tokens=* delims=" %%f in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" /f "%~2" ^| findstr /i "%~2"') do (
|
|||
|
%NSudo% reg add "%%f" /v Visibility /t REG_DWORD /d 1 /f
|
|||
|
%NSudo% reg add "%%f" /v DefVis /t REG_DWORD /d 2 /f
|
|||
|
%NSudo% reg delete "%%f\Owners" /f
|
|||
|
)
|
|||
|
call :UnMountImageRegistry
|
|||
|
|
|||
|
for /f "tokens=3 delims=: " %%f in ('%Dism% /English /Image:"%~1" /Get-Packages ^| findstr /i "%~2" ^| findstr /v %ImageLanguage%') do (
|
|||
|
echo.<2E>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD> [%%f]
|
|||
|
%Dism% /Image:"%~1" /Remove-Package /PackageName:"%%f" /Quiet
|
|||
|
)
|
|||
|
endlocal
|
|||
|
goto :eof
|
|||
|
|
|||
|
rem <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD> [ %~1 : ע<><D7A2><EFBFBD><EFBFBD>·<EFBFBD><C2B7> %~2 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7> ]
|
|||
|
:ImportRegistry
|
|||
|
if not exist "%~1" goto :eof
|
|||
|
call :RemoveFile "%TMP%\%~nx1"
|
|||
|
rem <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|||
|
for /f "delims=" %%f in ('type "%~1"') do (
|
|||
|
set str=%%f
|
|||
|
set "str=!str:HKEY_CURRENT_USER=HKEY_LOCAL_MACHINE\TK_NTUSER!"
|
|||
|
set "str=!str:HKEY_LOCAL_MACHINE\SOFTWARE=HKEY_LOCAL_MACHINE\TK_SOFTWARE!"
|
|||
|
set "str=!str:HKEY_LOCAL_MACHINE\SYSTEM=HKEY_LOCAL_MACHINE\TK_SYSTEM!"
|
|||
|
set "str=!str:CurrentControlSet=ControlSet001!"
|
|||
|
echo !str!>>"%TMP%\%~nx1"
|
|||
|
)
|
|||
|
call :MountImageRegistry "%~2%
|
|||
|
%NSudo% reg import "%TMP%\%~nx1" >nul 2>&1
|
|||
|
call :UnMountImageRegistry
|
|||
|
goto :eof
|
|||
|
|
|||
|
rem <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD> [ %~1 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7> ]
|
|||
|
:MountImageRegistry
|
|||
|
reg load HKLM\TK_NTUSER "%~1\Users\Default\ntuser.dat" >nul
|
|||
|
reg load HKLM\TK_SOFTWARE "%~1\Windows\System32\config\SOFTWARE" >nul
|
|||
|
reg load HKLM\TK_SYSTEM "%~1\Windows\System32\config\SYSTEM" >nul
|
|||
|
goto :eof
|
|||
|
|
|||
|
rem ж<><D0B6>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
|
|||
|
:UnMountImageRegistry
|
|||
|
reg unload HKLM\TK_NTUSER >nul 2>&1
|
|||
|
reg unload HKLM\TK_SOFTWARE >nul 2>&1
|
|||
|
reg unload HKLM\TK_SYSTEM >nul 2>&1
|
|||
|
goto :eof
|
|||
|
|
|||
|
rem ɾ<><C9BE><EFBFBD>ļ<EFBFBD> [ %~1 : <20>ļ<EFBFBD>·<EFBFBD><C2B7> ]
|
|||
|
:RemoveFile
|
|||
|
if exist "%~1" %NSudo% cmd.exe /c del /f /q "%~1"
|
|||
|
goto :eof
|
|||
|
|
|||
|
:Exit
|
|||
|
endlocal EnableDelayedExpansion
|
|||
|
title <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|