jblu

jblu / Skip_TPM_Check_on_Dynamic_Update.cmd

Last active 6 months ago

Like 0

jblu revised this gist 2 years ago · f81aaf4

No changes

jblu revised this gist 2 years ago · 7c9d221

1 file changed, 78 insertions

Skip_TPM_Check_on_Dynamic_Update.cmd (file created)
@@ -0,0 +1,78 @@
1 + @(set '(=)||' <# lean and mean cmd / powershell hybrid #> @'
2 +
3 + ::# Get 11 on 'unsupported' PC via Windows Update or mounted ISO (no patching needed)
4 + ::# if WU is stuck use windows_update_refresh.bat; Beta/Dev/Canary needs OfflineInsiderEnroll
5 + ::# V13: skip 2nd tpm check on Canary iso; no Server label; future proofing; tested with 26010 iso, wu and wu repair version
6 +
7 + @echo off & title get 11 on 'unsupported' PC || AveYo 2023.12.07
8 + if /i "%~f0" neq "%SystemDrive%\Scripts\get11.cmd" goto setup
9 + powershell -win 1 -nop -c ";"
10 + set CLI=%*& set SOURCES=%SystemDrive%\$WINDOWS.~BT\Sources& set MEDIA=.& set MOD=CLI& set PRE=WUA& set /a VER=11
11 + if not defined CLI (exit /b) else if not exist %SOURCES%\SetupHost.exe (exit /b)
12 + if not exist %SOURCES%\WindowsUpdateBox.exe mklink /h %SOURCES%\WindowsUpdateBox.exe %SOURCES%\SetupHost.exe
13 + reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v DisableWUfBSafeguards /d 1 /t reg_dword
14 + reg add HKLM\SYSTEM\Setup\MoSetup /f /v AllowUpgradesWithUnsupportedTPMorCPU /d 1 /t reg_dword
15 + set OPT=/Compat IgnoreWarning /MigrateDrivers All /Telemetry Disable
16 + set /a restart_application=0x800705BB & (call set CLI=%%CLI:%1 =%%)
17 + set /a incorrect_parameter=0x80070057 & (set SRV=%CLI:/Product Client =%)
18 + set /a launch_option_error=0xc190010a & (set SRV=%SRV:/Product Server =%)
19 + for %%W in (%CLI%) do if /i %%W == /PreDownload (set MOD=SRV)
20 + for %%W in (%CLI%) do if /i %%W == /InstallFile (set PRE=ISO& set "MEDIA=") else if not defined MEDIA set "MEDIA=%%~dpW"
21 + if %VER% == 11 for %%W in ("%MEDIA%appraiserres.dll") do if exist %%W if %%~zW == 0 set AlreadyPatched=1 & set /a VER=10
22 + if %VER% == 11 findstr /r "P.r.o.d.u.c.t.V.e.r.s.i.o.n...1.0.\..0.\..2.[2-9]" %SOURCES%\SetupHost.exe >nul 2>nul || set /a VER=10
23 + if %VER% == 11 if not exist "%MEDIA%EI.cfg" (echo;[Channel]>%SOURCES%\EI.cfg & echo;_Default>>%SOURCES%\EI.cfg)
24 + if %VER%_%PRE% == 11_ISO (%SOURCES%\WindowsUpdateBox.exe /Product Server /PreDownload /Quiet %OPT%)
25 + if %VER%_%PRE% == 11_ISO (del /f /q %SOURCES%\appraiserres.dll 2>nul & cd.>%SOURCES%\appraiserres.dll & call :canary)
26 + if %VER%_%MOD% == 11_SRV (set ARG=%OPT% %SRV% /Product Server)
27 + if %VER%_%MOD% == 11_CLI (set ARG=%OPT% %CLI%)
28 + %SOURCES%\WindowsUpdateBox.exe %ARG%
29 + if %errorlevel% == %restart_application% (call :canary & %SOURCES%\WindowsUpdateBox.exe %ARG%)
30 + exit /b
31 +
32 + :canary iso skip 2nd tpm check by AveYo
33 + set C= $X='%SOURCES%\hwreqchk.dll'; $Y='SQ_TpmVersion GTE 1'; $Z='SQ_TpmVersion GTE 0'; if (test-path $X) {
34 + set C=%C% try { takeown.exe /f $X /a; icacls.exe $X /grant *S-1-5-32-544:f; attrib -R -S $X; [io.file]::OpenWrite($X).close() }
35 + set C=%C% catch { return }; $R=[Text.Encoding]::UTF8.GetBytes($Z); $l=$R.Length; $i=2; $w=!1;
36 + set C=%C% $B=[io.file]::ReadAllBytes($X); $H=[BitConverter]::ToString($B) -replace '-';
37 + set C=%C% $S=[BitConverter]::ToString([Text.Encoding]::UTF8.GetBytes($Y)) -replace '-';
38 + set C=%C% do { $i=$H.IndexOf($S, $i + 2); if ($i -gt 0) { $w=!0; for ($k=0; $k -lt $l; $k++) { $B[$k + $i / 2]=$R[$k] } } }
39 + set C=%C% until ($i -lt 1); if ($w) { [io.file]::WriteAllBytes($X, $B); [GC]::Collect() } }
40 + if %VER%_%PRE% == 11_ISO powershell -nop -c iex($env:C) >nul 2>nul
41 + exit /b
42 +
43 + :setup
44 + ::# elevate with native shell by AveYo
45 + >nul reg add hkcu\software\classes\.Admin\shell\runas\command /f /ve /d "cmd /x /d /r set \"f0=%%2\"& call \"%%2\" %%3"& set _= %*
46 + >nul fltmc|| if "%f0%" neq "%~f0" (cd.>"%temp%\runas.Admin" & start "%~n0" /high "%temp%\runas.Admin" "%~f0" "%_:"=""%" & exit /b)
47 +
48 + ::# lean xp+ color macros by AveYo: %<%:af " hello "%>>% & %<%:cf " w\"or\"ld "%>% for single \ / " use .%|%\ .%|%/ \"%|%\"
49 + for /f "delims=:" %%s in ('echo;prompt $h$s$h:^|cmd /d') do set "|=%%s"&set ">>=\..\c nul&set /p s=%%s%%s%%s%%s%%s%%s%%s<nul&popd"
50 + set "<=pushd "%appdata%"&2>nul findstr /c:\ /a" &set ">=%>>%&echo;" &set "|=%|:~0,1%" &set /p s=\<nul>"%appdata%\c"
51 +
52 + ::# toggle when launched without arguments, else jump to arguments: "install" or "remove"
53 + set CLI=%*& (set IFEO=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options)
54 + wmic /namespace:"\\root\subscription" path __EventFilter where Name="Skip TPM Check on Dynamic Update" delete >nul 2>nul & rem v1
55 + reg delete "%IFEO%\vdsldr.exe" /f 2>nul & rem v2 - v5
56 + if /i "%CLI%"=="" reg query "%IFEO%\SetupHost.exe\0" /v Debugger >nul 2>nul && goto remove || goto install
57 + if /i "%~1"=="install" (goto install) else if /i "%~1"=="remove" goto remove
58 +
59 + :install
60 + mkdir %SystemDrive%\Scripts >nul 2>nul & copy /y "%~f0" "%SystemDrive%\Scripts\get11.cmd" >nul 2>nul
61 + reg add "%IFEO%\SetupHost.exe" /f /v UseFilter /d 1 /t reg_dword >nul
62 + reg add "%IFEO%\SetupHost.exe\0" /f /v FilterFullPath /d "%SystemDrive%\$WINDOWS.~BT\Sources\SetupHost.exe" >nul
63 + reg add "%IFEO%\SetupHost.exe\0" /f /v Debugger /d "%SystemDrive%\Scripts\get11.cmd" >nul
64 + echo;
65 + %<%:f0 " Skip TPM Check on Dynamic Update V13 "%>>% & %<%:2f " INSTALLED "%>>% & %<%:f0 " run again to remove "%>%
66 + if /i "%CLI%"=="" timeout /t 7
67 + exit /b
68 +
69 + :remove
70 + del /f /q "%SystemDrive%\Scripts\get11.cmd" "%Public%\get11.cmd" "%ProgramData%\get11.cmd" >nul 2>nul
71 + reg delete "%IFEO%\SetupHost.exe" /f >nul 2>nul
72 + echo;
73 + %<%:f0 " Skip TPM Check on Dynamic Update V13 "%>>% & %<%:df " REMOVED "%>>% & %<%:f0 " run again to install "%>%
74 + if /i "%CLI%"=="" timeout /t 7
75 + exit /b
76 +
77 + '@); $0 = "$env:temp\Skip_TPM_Check_on_Dynamic_Update.cmd"; ${(=)||} -split "\r?\n" | out-file $0 -encoding default -force; & $0
78 + # press enter