Skip to content

Commit

Permalink
feat: optimize/simplify bypass win11 requirements script
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyueta committed Oct 7, 2023
1 parent 7d4350e commit 2042c8a
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/release-zip/Bypass Windows 11 Requirements.cmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@echo off
setlocal EnableDelayedExpansion

title Bypass Windows 11 Requirements

cd /d "%~dp0"

:: set ANSI escape characters
for /f %%A in ('forfiles /m "%~nx0" /c "cmd /c echo 0x1B"') do set "ESC=%%A"
:: Set ANSI escape characters
for /f %%a in ('forfiles /m "%~nx0" /c "cmd /c echo 0x1B"') do set "ESC=%%a"
set "right=%ESC%[<x>C"
set "bullet= %ESC%[34m-%ESC%[0m"

Expand All @@ -25,27 +25,25 @@ echo %bullet% Core isolation
echo %bullet% Windows Hello
echo %bullet% BitLocker
echo]
echo This list could expand in the future, and might
echo This list could expand in the future and might
echo not cover everything.
echo]
<nul set /p=%right:<x>=2%%ESC%[1m%ESC%[33mType 'I understand' to continue: %ESC%[0m

:: This forces the user to type 'I understand' on the same line
setlocal EnableDelayedExpansion
set "str=I understand"
for /l %%A in (0 1 12) do (
if not "!str:~%%A,1!"=="" call :xcopyInput "!str:~%%A,1!"
for /l %%a in (0 1 12) do (
if not "!str:~%%a,1!"=="" call :xcopyInput "!str:~%%a,1!"
)
endlocal
echo]
echo %ESC%[2A%ESC%[?25l

:runCommands
set regCommands=reg add HKLM\SYSTEM\Setup\LabConfig /v BypassTPMCheck /t REG_DWORD /d 1 /f ^^^> nul 2^^^>^^^&1 ^^^& ^
reg add HKLM\SYSTEM\Setup\LabConfig /v BypassSecureBootCheck /t REG_DWORD /d 1 /f ^^^> nul 2^^^>^^^&1 ^^^& ^
reg add HKLM\SYSTEM\Setup\LabConfig /v BypassRAMCheck /t REG_DWORD /d 1 /f ^^^> nul 2^^^>^^^&1
set regCommands=reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassTPMCheck" /t REG_DWORD /d "1" /f ^^^> nul 2^^^>^^^&1 ^^^& ^
reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassSecureBootCheck" /t REG_DWORD /d "1" /f ^^^> nul 2^^^>^^^&1 ^^^& ^
reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d "1" /f ^^^> nul 2^^^>^^^&1

fltmc >nul 2>&1
fltmc > nul 2>&1
if not "%errorlevel%"=="0" (
powershell -NoP Start -WindowStyle Hidden -Verb RunAs 'cmd.exe' -ArgumentList '/c %regCommands%' > nul 2>&1 || (
set retry=true
Expand All @@ -70,16 +68,15 @@ exit /b

:errorText <"action">
echo %ESC%[31m Error! %ESC%[0mPress any key to %~1... %ESC%[1A
exit /b
exit /b 1

:xcopyInput <"key">
set "key="
setlocal DisableDelayedExpansion
for /f "delims=" %%C in ('2^>nul xcopy.exe /w /l "%~f0" "%~f0"') do if not defined key set "key=%%C"
endlocal && set^ ^"key=^^%key:~-1%^" !
if /i "!key!"=="%~1" (
if "%~1"==" " (
for /f "delims=" %%a in ('2^>nul xcopy.exe /w /l "%~f0" "%~f0"') do if not defined key set "key=%%a"
set "key=!key:~-1!"
if /i "%key%" == "%~1" (
if "%~1" == " " (
<nul set /p=%right:<x>=1%
) else <nul set /p=%~1
) else goto :xcopyInput
exit /b 0
exit /b

0 comments on commit 2042c8a

Please sign in to comment.