Advertisement
-zens

Disable-CPU-Idle

Nov 12th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.74 KB | Source Code | 0 0
  1. @echo off
  2. :: Enable ANSI support for colors in the terminal
  3. cd /d "%~dp0"
  4. for /f %%a in ('forfiles /m "%~nx0" /c "cmd /c echo 0x1B"') do set "ESC=%%a"
  5. chcp 65001 > nul
  6.  
  7. title Zensware CPU Idle State Toggle
  8. mode con: cols=70 lines=24
  9.  
  10. :: Set colors for a refined GUI
  11. set "color_pink=%ESC%[35m"
  12. set "color_white=%ESC%[37m"
  13. set "color_reset=%ESC%[0m"
  14. set "color_green=%ESC%[32m"
  15. set "color_yellow=%ESC%[33m"
  16. set "color_cyan=%ESC%[36m"
  17.  
  18. :menu
  19. cls
  20. echo %color_pink%
  21. echo %ESC%[1m███████╗███████╗███╗░░██╗░██████╗░██╗░░░░░░░██╗░█████╗░██████╗░███████╗%color_reset%
  22. echo %color_pink%╚════██║██╔════╝████╗░██║██╔════╝░██║░░██╗░░██║██╔══██╗██╔══██╗██╔════╝%color_reset%
  23. echo %color_pink%░░███╔═╝█████╗░░██╔██╗██║╚█████╗░░╚██╗████╗██╔╝███████║██████╔╝█████╗░░%color_reset%
  24. echo %color_pink%██╔══╝░░██╔══╝░░██║╚████║░╚═══██╗░░████╔═████║░██╔══██║██╔══██╗██╔══╝░░%color_reset%
  25. echo %color_pink%███████╗███████╗██║░╚███║██████╔╝░░╚██╔╝░╚██╔╝░██║░░██║██║░░██║███████╗%color_reset%
  26. echo %color_pink%╚══════╝╚══════╝╚═╝░░╚══╝╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝░░╚═╝╚═╝░░╚═╝╚══════╝%color_reset%
  27. echo %color_white%
  28. echo %color_white%Options:%color_reset%
  29. echo.
  30. echo    1. Disable Idle States
  31. echo    2. Restore Default Idle State
  32. echo    3. Exit
  33. echo.
  34. echo.
  35.  
  36. :: Check if hyper-threading/SMT is enabled
  37. powershell -NonI -NoP -C "Get-CimInstance Win32_Processor | Foreach-Object { if ([int]$_.NumberOfLogicalProcessors -gt [int]$_.NumberOfCores) { exit 262 } }"
  38. if "%errorlevel%"=="262" goto :hyperThreadingWarning
  39.  
  40. set /p choice="Option: "
  41.  
  42. if "%choice%"=="1" goto disable_idle
  43. if "%choice%"=="2" goto restore_default
  44. if "%choice%"=="3" exit
  45. goto menu
  46.  
  47. :disable_idle
  48. cls
  49. echo %color_yellow%Disabling CPU Idle States (Full Performance Mode)...%color_reset%
  50. powercfg /setacvalueindex scheme_current sub_processor 5d76a2ca-e8c0-402f-a133-2158492d58ad 1
  51. powercfg /setactive scheme_current
  52. echo %color_yellow%CPU idle states have been disabled. CPU will now run at full performance.%color_reset%
  53. pause
  54. goto menu
  55.  
  56. :restore_default
  57. cls
  58. echo %color_cyan%Restoring Default Idle State...%color_reset%
  59. powercfg /setacvalueindex scheme_current sub_processor 5d76a2ca-e8c0-402f-a133-2158492d58ad 0
  60. powercfg /setactive scheme_current
  61. echo %color_cyan%Default CPU idle state has been restored.%color_reset%
  62. pause
  63. goto menu
  64.  
  65. :hyperThreadingWarning
  66. cls
  67. echo %color_green%
  68. echo    Hyper-Threading/SMT Detected
  69. echo    ──────────────────────────────────────────
  70. echo %color_yellow%  Warning:%color_reset% You %color_white%should not disable idle states %color_reset%when
  71. echo    this feature is enabled as it can cause
  72. echo    worse overall CPU performance.
  73. echo.
  74. echo    You may disable Hyper-Threading/SMT in the BIOS
  75. echo    or consider disabling C-states instead.
  76. echo.
  77. echo    %color_white%Press any key to exit...%color_reset%
  78. pause > nul
  79. exit /b 1
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement