Advertisement
Guest User

PAE Patch

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