Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- cd /d "%~dp0"
- bcdedit /enum >nul 2>&1
- if %errorlevel% neq 0 goto no-bcdedit
- set current=0
- FOR /F %%a in ('bcdedit /enum ^| find "{current}"') do set current=1
- if %current% equ 0 goto no-current
- set patched=0
- FOR /F %%a in ('bcdedit /enum ^| find "ntkrnlpx.exe"') do set patched=1
- set winload=0
- FOR /F %%a in ('bcdedit /enum {current} ^| find "%systemroot:~2%\system32\winload.exe"') do set winload=1
- FOR /F %%a in ('bcdedit /enum {current} ^| find "%systemroot:~2%\system32\winloadx.exe"') do set winload=1
- if %winload% equ 0 goto no-loader
- set windows=0
- FOR /F %%a in ('bcdedit /enum {current} ^| find "Windows 7"') do set windows=7
- FOR /F %%a in ('bcdedit /enum {current} ^| find "Windows 8"') do set windows=8
- FOR /F %%a in ('bcdedit /enum {current} ^| find "Windows 10"') do set windows=10
- if %windows% equ 7 if not exist "%systemroot%\system32\ntkrnlpa.exe" goto no-kernel
- if %windows% equ 8 if not exist "%systemroot%\system32\ntoskrnl.exe" goto no-kernel
- if %windows% equ 10 if not exist "%systemroot%\system32\ntoskrnl.exe" goto no-kernel
- if %windows% equ 0 goto no-windows
- :patch-kernel
- echo - Executing Kernel patch.
- if %windows% equ 7 set kernel=ntkrnlpa.exe
- if %windows% equ 8 set kernel=ntoskrnl.exe
- if %windows% equ 10 set kernel=ntoskrnl.exe
- Patchpae -type kernel -o "%systemroot%\system32\ntkrnlpx.exe" "%systemroot%\system32\%kernel%" >nul 2>&1
- if %errorlevel% neq 0 goto no-kpatch
- Patchpae -type loader -o "%systemroot%\system32\winloadx.exe" "%systemroot%\system32\winload.exe" >nul 2>&1
- if %errorlevel% neq 0 goto no-lpatch
- if %patched% equ 1 goto finished
- :boot-manager
- echo - Adding Boot entry.
- FOR /F "tokens=2 delims={}" %%g in ('bcdedit /copy {current} /d "Windows %windows% (PAE)"') do set newguid=%%g
- bcdedit /set {%newguid%} kernel "ntkrnlpx.exe" >nul 2>&1
- bcdedit /set {%newguid%} path "%systemroot:~2%\system32\winloadx.exe" >nul 2>&1
- bcdedit /set {%newguid%} nointegritychecks yes >nul 2>&1
- bcdedit /set {bootmgr} default {%newguid%} >nul 2>&1
- bcdedit /set {bootmgr} displaybootmenu yes >nul 2>&1
- bcdedit /set {bootmgr} timeout 3 >nul 2>&1
- goto finished
- :no-bcdedit
- echo - ERROR, Command bcdedit missing! & goto end
- :no-kpatch
- echo - ERROR, Cannot patch Kernel! & goto end
- :no-lpatch
- echo - ERROR, Cannot patch Loader! & goto end
- :no-kernel
- echo - ERROR, Cannot find Kernel! & goto end
- :no-loader
- echo - ERROR, Cannot detect Loader! & goto end
- :no-windows
- echo - ERROR, Unsupported Windows edition! & goto end
- :no-current
- echo - ERROR, Unsupported Boot config! & goto end
- :finished
- echo - Success, All done!
- :end
- ping 127.0.0.1 -n 6 >nul 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement