batch script choose 1 or 2 registry setting


shoober420

Active member
Member
Local time
4:41 AM
Posts
127
OS
Windows 11 27783
i was googling how to do a batch script choice by numbers, like 1 and 2. i came across a template and adjusted the settings to correlate with the choices desired.

Code:
ECHO off
cls
:start
ECHO.
ECHO 1. Print Latency
ECHO 2. Print Performance
set choice=
set /p choice=Press 1 for Latency / Press 2 for Performance
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' reg add "HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl" /v "Win32PrioritySeparation" /t REG_DWORD /d "0x00000028" /f
if '%choice%'=='1' reg add "HKLM\SYSTEM\ControlSet001\Control\PriorityControl" /v "Win32PrioritySeparation" /t REG_DWORD /d "0x00000028" /f
if '%choice%'=='2' reg add "HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl" /v "Win32PrioritySeparation" /t REG_DWORD /d "0x00000016" /f
if '%choice%'=='2' reg add "HKLM\SYSTEM\ControlSet001\Control\PriorityControl" /v "Win32PrioritySeparation" /t REG_DWORD /d "0x00000016" /f
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:hello
ECHO Latency
goto end
:bye
ECHO Performance
goto end
:end

PAUSE

i wont be at a computer for another couple days. does this look like it will work, with 1 being Latency registry keys and 2 being Performance registry keys?
 
Windows Build/Version
Windows 27729
Last edited:

My Computer

System One

  • OS
    Windows 11 27783
    Computer type
    PC/Desktop
    CPU
    Intel i7 7700 @4.0ghz
    Memory
    64gb DDR4
    Graphics Card(s)
    Radeon RX 5500 XT
    Other Info
    https://www.github.com/shoober420
I am not familiar with modern Command Prompt, if the syntax is correct, it should work. Back in good old MS-DOS the condition was
if errorlevel%== or similar.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 (build 22631.4249) test laptop, Windows 11 Pro v24H2 (build 26100.2894) main PC
    Computer type
    Laptop
    Manufacturer/Model
    Acer Extensa 5630EZ
    CPU
    Mobile DualCore Intel Core 2 Duo T7250, 2000 MHz
    Motherboard
    Acer Extensa 5630
    Memory
    4GB
    Graphics Card(s)
    Mobile Intel(R) GMA 4500M (Mobile 4 series)
    Sound Card
    Realtek ALC268 @ Intel 82801IB ICH9 - High Definition Audio Controller
    Monitor(s) Displays
    1
    Screen Resolution
    1280x800
    Hard Drives
    Samsung SSD 850 EVO 250GB SATA Device (250 GB, SATA-III)
    Internet Speed
    VDSL 50 Mbps
    Browser
    MICROSOFT EDGE
    Antivirus
    WINDOWS DEFENDER
    Other Info
    Legacy MBR installation, no TPM, no Secure Boot, no WDDM 2.0 graphics drivers, no SSE4.2, cannot get more unsupported ;) This is only my test laptop. I had installed Windows 11 here before upgrading my main PC. For my main PC I use everyday see my 2nd system specs.
  • Operating System
    Windows 11 Pro v24H2 (build 26100.2894)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom-built PC
    CPU
    Intel Core-i7 3770 3.40GHz s1155 (3rd generation)
    Motherboard
    Asus P8H61 s1155 ATX
    Memory
    2x Kingston Hyper-X Blu 8GB DDR3-1600
    Graphics card(s)
    Gainward NE5105T018G1-1070F (nVidia GeForce GTX 1050Ti 4GB GDDR5)
    Sound Card
    Realtek HD audio (ALC887)
    Monitor(s) Displays
    Sony Bravia KDL-19L4000 19" LCD TV via VGA
    Screen Resolution
    1440x900 32-bit 60Hz
    Hard Drives
    WD Blue SA510 2.5 1000GB SSD as system disk, Western Digital Caviar Purple 4TB SATA III (WD40PURZ) as second
    PSU
    Thermaltake Litepower RGB 550W Full Wired
    Case
    SUPERCASE MIDI-TOWER
    Cooling
    Deepcool Gamma Archer CPU cooler, 1x 8cm fan at the back
    Mouse
    Sunnyline OptiEye PS/2
    Keyboard
    Mitsumi 101-key PS/2
    Internet Speed
    100Mbps
    Browser
    Microsoft Edge, Mozilla Firefox
    Antivirus
    Microsoft Windows Defender
    Other Info
    Legacy BIOS (MBR) installation, no TPM, no Secure Boot, WDDM 3.0 graphics drivers, WEI score 7.4
Performance registry keys?
I've made some modifications and this is what I got. I also added a return to default setting. Give it a try.
echo off
:: Created by Dronix7 07.11.2024 UpDated 07.11.2024
:_Start
mode con:cols=50 lines=17
color F0 & cls
echo.
echo 1. Latency Configuration
echo 2. Performance Configuration
echo 3. Standard Configuration
echo.
set choice=
set /p choice=. Select Item and Enter or Enter to Exit:
echo.
:: =================================================================================================================================================
if %choice% == 1 set Par="0x00000028" & set Message=The Latency Configuration Has Been Applied & goto :_Continue
if %choice% == 2 set Par="0x00000016" & set Message=The Performance Configuration Has Been Applied & goto :_Continue
if %choice% == 3 set Par="0x00000026" & set Message=The Standard Configuration Has Been Applied & goto :_Continue
echo Out Of Range. To Continue, Press Enter & echo. & pause & goto :_Start
:: =================================================================================================================================================
:_Continue
reg add "HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl" /v "Win32PrioritySeparation" /t REG_DWORD /d "%Par%" /f
reg add "HKLM\SYSTEM\ControlSet001\Control\PriorityControl" /v "Win32PrioritySeparation" /t REG_DWORD /d "%Par%" /f & echo.
echo %Message%
:: =================================================================================================================================================
echo.
echo 0 - Continue Choosing
echo Enter - Exit
echo.
set Variant=
set /p Variant="Make Your Choice and Press Enter (0 or Enter): "
echo.
if "%Variant%"== "0" goto :_Start
if "%Variant%"==""
:: =================================================================================================================================================
Ready bat file - Selecting Items
 

My Computer

System One

  • OS
    Windows 11 Stable, Release Preview, Beta, Dev, Canary
    Computer type
    PC/Desktop
    Manufacturer/Model
    Micro-Star International Co., Ltd. MS-7D54
    CPU
    AMD Ryzen 9 PRO 5950X
    Motherboard
    MSI MAG X570S Tomahawk Max WiFi (MS-7D54) (2 PCI-E x1, 2 PCI-E x16, 2 M.2, 4 DDR4 DIMM, Audio, Video, 2.5GbE LAN, WiFi)
    Memory
    128 Gb
    Graphics Card(s)
    Intel(R) Arc(TM) A380 Graphics (2 ГБ)
    Sound Card
    Устройство с поддержкой High Definition Audio
    Monitor(s) Displays
    HP X34 [34" LCD] (6CM1300J5J) {2021}
    Screen Resolution
    3440x1440
    Hard Drives
    KINGSTON SFYRD2000G (2000 ГБ, PCI-E 4.0 x4)
    PSU
    Be Quiet! Dark Rock Pro 4
    Case
    Cooler Master HAF XB EVO
    Internet Speed
    1000 Mb/s
    Browser
    Chrome
    Antivirus
    Windows Defender
You may want to consider using the built-in choice command, which can limit the user to choosing a valid option, rather than just typing in any value.

Batch:
echo.
echo 1. Latency Configuration
echo 2. Performance Configuration
echo 3. Standard Configuration
echo C. Cancel
echo.
choice /c 123C /m "Choose an option :"

if 4 EQU %ERRORLEVEL% (
   echo User chose to cancel.
) else if 3 EQU %ERRORLEVEL% (
   echo User chose option 3.
) else if 2 EQU %ERRORLEVEL% (
   echo User chose option 2.
) else if 1 EQU %ERRORLEVEL% (
   echo User chose option 1.
) else if 0 EQU %ERRORLEVEL% (
   echo User bailed out.
)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
You may want to consider using the built-in choice command
I like what you've done, but I didn't understand where the sound comes from when selecting a value outside the selected range.
 

My Computer

System One

  • OS
    Windows 11 Stable, Release Preview, Beta, Dev, Canary
    Computer type
    PC/Desktop
    Manufacturer/Model
    Micro-Star International Co., Ltd. MS-7D54
    CPU
    AMD Ryzen 9 PRO 5950X
    Motherboard
    MSI MAG X570S Tomahawk Max WiFi (MS-7D54) (2 PCI-E x1, 2 PCI-E x16, 2 M.2, 4 DDR4 DIMM, Audio, Video, 2.5GbE LAN, WiFi)
    Memory
    128 Gb
    Graphics Card(s)
    Intel(R) Arc(TM) A380 Graphics (2 ГБ)
    Sound Card
    Устройство с поддержкой High Definition Audio
    Monitor(s) Displays
    HP X34 [34" LCD] (6CM1300J5J) {2021}
    Screen Resolution
    3440x1440
    Hard Drives
    KINGSTON SFYRD2000G (2000 ГБ, PCI-E 4.0 x4)
    PSU
    Be Quiet! Dark Rock Pro 4
    Case
    Cooler Master HAF XB EVO
    Internet Speed
    1000 Mb/s
    Browser
    Chrome
    Antivirus
    Windows Defender
I like what you've done, but I didn't understand where the sound comes from when selecting a value outside the selected range.
It's a built-in handy beep feature, provided free of charge by Windows. :)

"If the user presses a key that is not a valid choice, choice sounds a warning beep."

 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
You may want to consider using the built-in choice command
I love using the CHOICE command. If (as I do) you ever want to use it for a batch file in the WinPE environment, such as a booting to a command prompt with a Windows install usb, then you need to copy C:\Windows\System32\choice.exe to the same folder on the usb as your batch file.
 

My Computers

System One System Two

  • OS
    Windows 11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Acer Aspire 3 A315-23
    CPU
    AMD Athlon Silver 3050U
    Memory
    8GB
    Graphics Card(s)
    Radeon Graphics
    Monitor(s) Displays
    laptop screen
    Screen Resolution
    1366x768 native resolution, up to 2560x1440 with Radeon Virtual Super Resolution
    Hard Drives
    1TB Samsung EVO 870 SSD
    Internet Speed
    50 Mbps
    Browser
    Edge, Firefox
    Antivirus
    Defender
    Other Info
    fully 'Windows 11 ready' laptop. Windows 10 C: partition migrated from my old unsupported 'main machine' then upgraded to 11. A test migration ran Insider builds for 2 months. When 11 was released on 5th October 2021 it was re-imaged back to 10 and was offered the upgrade in Windows Update on 20th October. Windows Update offered the 22H2 Feature Update on 20th September 2022. It got the 23H2 Feature Update on 4th November 2023 through Windows Update, and 24H2 on 3rd October 2024 through Windows Update by setting the Target Release Version for 24H2.

    My SYSTEM THREE is a Dell Latitude 5410, i7-10610U, 32GB RAM, 512GB NVMe ssd, supported device running Windows 11 Pro (and all my Hyper-V VMs).

    My SYSTEM FOUR is a 2-in-1 convertible Lenovo Yoga 11e 20DA, Celeron N2930, 8GB RAM, 256GB ssd. Unsupported device: currently running Win10 Pro, plus Win11 Pro RTM and Insider Dev, Beta, and RP 24H2 as native boot vhdx.

    My SYSTEM FIVE is a Dell Latitude 3190 2-in-1, Pentium Silver N5030, 8GB RAM, 512GB NVMe ssd, supported device running Windows 11 Pro, plus the Insider Beta, Dev, Canary, and Release Preview builds as a native boot .vhdx.
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude E4310
    CPU
    Intel® Core™ i5-520M
    Motherboard
    0T6M8G
    Memory
    8GB
    Graphics card(s)
    (integrated graphics) Intel HD Graphics
    Screen Resolution
    1366x768
    Hard Drives
    500GB Crucial MX500 SSD
    Browser
    Firefox, Edge
    Antivirus
    Defender
    Other Info
    unsupported machine: Legacy bios, MBR, TPM 1.2, upgraded from W10 to W11 using W10/W11 hybrid install media workaround. In-place upgrade to 22H2 using ISO and a workaround. Feature Update to 23H2 by manually installing the Enablement Package. In-place upgrade to 24H2 using hybrid 23H2/24H2 install media. Also running Insider Beta, Dev, and Canary builds as a native boot .vhdx.

    My SYSTEM THREE is a Dell Latitude 5410, i7-10610U, 32GB RAM, 512GB NVMe ssd, supported device running Windows 11 Pro (and all my Hyper-V VMs).

    My SYSTEM FOUR is a 2-in-1 convertible Lenovo Yoga 11e 20DA, Celeron N2930, 8GB RAM, 256GB ssd. Unsupported device: currently running Win10 Pro, plus Win11 Pro RTM and Insider Dev, Beta, and RP 24H2 as native boot vhdx.

    My SYSTEM FIVE is a Dell Latitude 3190 2-in-1, Pentium Silver N5030, 8GB RAM, 512GB NVMe ssd, supported device running Windows 11 Pro, plus the Insider Beta, Dev, Canary, and Release Preview builds as a native boot .vhdx.
To expand on @pseymour's example, you should use call subroutines so your script is more readable.
Code:
@echo off

echo.
echo 1. Latency Configuration
echo 2. Performance Configuration
echo 3. Standard Configuration
echo C. Cancel
echo.
choice /c 123C /m "Choose an option :"

if 4 EQU %ERRORLEVEL% (
   echo User chose to cancel.
) else if 3 EQU %ERRORLEVEL% (
   call :standard
) else if 2 EQU %ERRORLEVEL% (
   call :performance
) else if 1 EQU %ERRORLEVEL% (
   call :latency
) else if 0 EQU %ERRORLEVEL% (
   echo User bailed out.
)

goto :eof

:latency
echo User chose Latency option.
echo reg add ...
exit /b

:performance
echo User chose Performance option.
echo reg add ...
exit /b

:standard
echo User chose Standard option.
echo reg add ...
exit /b
 

My Computer

System One

  • OS
    Windows 7

My Computer

System One

  • OS
    Windows 11

My Computer

System One

  • OS
    Windows 11 27783
    Computer type
    PC/Desktop
    CPU
    Intel i7 7700 @4.0ghz
    Memory
    64gb DDR4
    Graphics Card(s)
    Radeon RX 5500 XT
    Other Info
    https://www.github.com/shoober420

Latest Tutorials

Back
Top Bottom