Advertisement
Guest User

PAE Patch

a guest
Sep 3rd, 2015
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.59 KB | None | 0 0
  1. @echo off
  2. cd /d "%~dp0"
  3.  
  4. bcdedit /enum >nul 2>&1
  5. if %errorlevel% neq 0 goto no-bcdedit
  6. set current=0
  7. FOR /F %%a in ('bcdedit /enum ^| find "{current}"') do set current=1
  8. if %current% equ 0 goto no-current
  9. set patched=0
  10. FOR /F %%a in ('bcdedit /enum ^| find "ntkrnlpx.exe"') do set patched=1
  11. set winload=0
  12. FOR /F %%a in ('bcdedit /enum {current} ^| find "%systemroot:~2%\system32\winload.exe"') do set winload=1
  13. FOR /F %%a in ('bcdedit /enum {current} ^| find "%systemroot:~2%\system32\winloadx.exe"') do set winload=1
  14. if %winload% equ 0 goto no-loader
  15. set windows=0
  16. FOR /F %%a in ('bcdedit /enum {current} ^| find "Windows 7"') do set windows=7
  17. FOR /F %%a in ('bcdedit /enum {current} ^| find "Windows 8"') do set windows=8
  18. FOR /F %%a in ('bcdedit /enum {current} ^| find "Windows 10"') do set windows=10
  19. if %windows% equ 7 if not exist "%systemroot%\system32\ntkrnlpa.exe" goto no-kernel
  20. if %windows% equ 8 if not exist "%systemroot%\system32\ntoskrnl.exe" goto no-kernel
  21. if %windows% equ 10 if not exist "%systemroot%\system32\ntoskrnl.exe" goto no-kernel
  22. if %windows% equ 0 goto no-windows
  23.  
  24. :patch-kernel
  25. echo - Executing Kernel patch.
  26. if %windows% equ 7 set kernel=ntkrnlpa.exe
  27. if %windows% equ 8 set kernel=ntoskrnl.exe
  28. if %windows% equ 10 set kernel=ntoskrnl.exe
  29. Patchpae -type kernel -o "%systemroot%\system32\ntkrnlpx.exe" "%systemroot%\system32\%kernel%" >nul 2>&1
  30. if %errorlevel% neq 0 goto no-kpatch
  31. Patchpae -type loader -o "%systemroot%\system32\winloadx.exe" "%systemroot%\system32\winload.exe" >nul 2>&1
  32. if %errorlevel% neq 0 goto no-lpatch
  33. if %patched% equ 1 goto finished
  34.  
  35. :boot-manager
  36. echo - Adding Boot entry.
  37. FOR /F "tokens=2 delims={}" %%g in ('bcdedit /copy {current} /d "Windows %windows% (PAE)"') do set newguid=%%g
  38. bcdedit /set {%newguid%} kernel "ntkrnlpx.exe" >nul 2>&1
  39. bcdedit /set {%newguid%} path "%systemroot:~2%\system32\winloadx.exe" >nul 2>&1
  40. bcdedit /set {%newguid%} nointegritychecks yes >nul 2>&1
  41. bcdedit /set {bootmgr} default {%newguid%} >nul 2>&1
  42. bcdedit /set {bootmgr} displaybootmenu yes >nul 2>&1
  43. bcdedit /set {bootmgr} timeout 3 >nul 2>&1
  44. goto finished
  45.  
  46. :no-bcdedit
  47. echo - ERROR, Command bcdedit missing! & goto end
  48. :no-kpatch
  49. echo - ERROR, Cannot patch Kernel! & goto end
  50. :no-lpatch
  51. echo - ERROR, Cannot patch Loader! & goto end
  52. :no-kernel
  53. echo - ERROR, Cannot find Kernel! & goto end
  54. :no-loader
  55. echo - ERROR, Cannot detect Loader! & goto end
  56. :no-windows
  57. echo - ERROR, Unsupported Windows edition! & goto end
  58. :no-current
  59. echo - ERROR, Unsupported Boot config! & goto end
  60. :finished
  61. echo - Success, All done!
  62. :end
  63. ping 127.0.0.1 -n 6 >nul 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement