@echo off setlocal :: ===== Admin check ===== >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' NEQ '0' ( echo Please run this script as Administrator! pause exit /b ) :: ===== Configuration ===== set "OSCDIMG=C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\oscdimg.exe" set "ISO_PATH=D:\win11\Win11_24H2_English_x64.iso" set "WORK_DIR=D:\ISO_Mod" set "NEW_ISO=D:\win11\Win11_24H2_English_x64_Bypass.iso" :: ===== Check oscdimg ===== if not exist "%OSCDIMG%" ( echo Not find oscdimg tool. Please check OSCDIMG path. pause exit /b 1 ) :: ===== Create working directory ===== if exist "%WORK_DIR%" rd /s /q "%WORK_DIR%" mkdir "%WORK_DIR%" :: ===== Mount ISO and get drive letter ===== echo [INFO] Mounting ISO... for /f "usebackq tokens=*" %%D in (`powershell -NoProfile -Command ^ "$d = Mount-DiskImage -ImagePath '%ISO_PATH%' -PassThru | Get-Volume; Write-Output $d.DriveLetter"`) do set "ISODRIVE=%%D:" if not exist "%ISODRIVE%\" ( echo [Error] ISO mount failed pause exit /b 1 ) echo [INFO] ISO mounted at %ISODRIVE% :: ===== Copy ISO contents ===== echo [INFO] Copy ISO Files... xcopy "%ISODRIVE%\*" "%WORK_DIR%\" /E /H /K >nul :: ===== Dismount ISO ===== powershell Dismount-DiskImage -ImagePath "%ISO_PATH%" >nul :: ===== Create Autounattend.xml ===== echo [INFO] Generate Autounattend.xml... ( echo ^ echo ^ echo ^ echo ^ echo ^ echo ^1^ echo ^reg add HKLM\SYSTEM\Setup\LabConfig /v BypassTPMCheck /t REG_DWORD /d 1 /f^ echo ^ echo ^ echo ^2^ echo ^reg add HKLM\SYSTEM\Setup\LabConfig /v BypassSecureBootCheck /t REG_DWORD /d 1 /f^ echo ^ echo ^ echo ^ echo ^ echo ^ ) > "%WORK_DIR%\Autounattend.xml" :: ===== Create New ISO ===== echo [INFO] Creating new ISO... "%OSCDIMG%" -m -o -u2 -udfver102 "%WORK_DIR%" "%NEW_ISO%" echo. echo [DONE] New ISO created: echo %NEW_ISO% pause