batch script choose 1 or 2 registry setting


shoober420

Well-known member
Member
VIP
Local time
4:37 AM
Posts
231
OS
Windows 11 27965
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 My Computer

At a glance

Windows 11 27965Intel i7 7700 @4.0ghz64gb DDR4Radeon RX 5500 XT
OS
Windows 11 27965
Computer type
PC/Desktop
CPU
Intel i7 7700 @4.0ghz
Memory
64gb DDR4
Graphics Card(s)
Radeon RX 5500 XT
Sound Card
Topping D50s
Hard Drives
NVMe
PSU
Corsair
Keyboard
Stelseries G6v2
Mouse
Zowie EC2
Other Info
https://www.youtube.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 My Computers

  • At a glance

    Windows 11 Pro 23H2 (5699), 25H2 (8655)Mobile DualCore Intel Core 2 Duo T7250, 2000 MHz4GBMobile Intel(R) GMA 4500M (Mobile 4 series)
    OS
    Windows 11 Pro 23H2 (5699), 25H2 (8655)
    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.
  • At a glance

    Windows 11 Pro v25H2 (build 26200.8655)Intel Core-i7 3770 3.40GHz s1155 (3rd generat...2x Kingston Hyper-X Blu 8GB DDR3-1600GIGABYTE GeForce RTX 3050 WINDFORCE OC V2 6GB...
    Operating System
    Windows 11 Pro v25H2 (build 26200.8655)
    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)
    GIGABYTE GeForce RTX 3050 WINDFORCE OC V2 6GB (GV-N3050WF2OCV2-6GD)
    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
    Keyboard
    Mitsumi 101-key PS/2
    Mouse
    Sunnyline OptiEye 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 My Computer

At a glance

Windows 11 Stable, Beta, Dev, CanaryAMD Ryzen 9 PRO 5950X128 GbIntel(R) Arc(TM) A380 Graphics (2 ГБ)
OS
Windows 11 Stable, 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
@Dronix this looks amazing, i cant wait to try this in a couple days. very nice work
 

My Computer My Computer

At a glance

Windows 11 27965Intel i7 7700 @4.0ghz64gb DDR4Radeon RX 5500 XT
OS
Windows 11 27965
Computer type
PC/Desktop
CPU
Intel i7 7700 @4.0ghz
Memory
64gb DDR4
Graphics Card(s)
Radeon RX 5500 XT
Sound Card
Topping D50s
Hard Drives
NVMe
PSU
Corsair
Keyboard
Stelseries G6v2
Mouse
Zowie EC2
Other Info
https://www.youtube.com/shoober420
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 Computer My Computer

At a glance

Windows 11 Pro 25H212th Gen Core i7-1260P64 GB Micron PC4-25600Intel Iris Xe Graphics
OS
Windows 11 Pro 25H2
Computer type
PC/Desktop
Manufacturer/Model
Intel NUC12WSHi7
CPU
12th Gen Core i7-1260P
Motherboard
NUC12WSBi7
Memory
64 GB Micron PC4-25600
Graphics Card(s)
Intel Iris Xe Graphics
Sound Card
on-board Realtek HD Audio
Monitor(s) Displays
Dell U3219Q
Screen Resolution
3840 x 2160
Hard Drives
Samsung SSD 990 PRO 1TB
Crucial MX500 2 TB
Antivirus
Microsoft Defender
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 My Computer

At a glance

Windows 11 Stable, Beta, Dev, CanaryAMD Ryzen 9 PRO 5950X128 GbIntel(R) Arc(TM) A380 Graphics (2 ГБ)
OS
Windows 11 Stable, 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 Computer My Computer

At a glance

Windows 11 Pro 25H212th Gen Core i7-1260P64 GB Micron PC4-25600Intel Iris Xe Graphics
OS
Windows 11 Pro 25H2
Computer type
PC/Desktop
Manufacturer/Model
Intel NUC12WSHi7
CPU
12th Gen Core i7-1260P
Motherboard
NUC12WSBi7
Memory
64 GB Micron PC4-25600
Graphics Card(s)
Intel Iris Xe Graphics
Sound Card
on-board Realtek HD Audio
Monitor(s) Displays
Dell U3219Q
Screen Resolution
3840 x 2160
Hard Drives
Samsung SSD 990 PRO 1TB
Crucial MX500 2 TB
Antivirus
Microsoft Defender
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 My Computers

  • At a glance

    Windows 11 HomeAMD Athlon Silver 3050U8GBRadeon Graphics
    OS
    Windows 11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Acer Aspire 3 A315-23-R9VY
    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 (from April 2026: 250GB EVO 850)
    Internet Speed
    150 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, 24H2 on 3rd October 2024 through Windows Update by setting the Target Release Version for 24H2, and 25H2 on 30th September 2025 through Windows Update by setting the Target Release Version for 25H2.

    UPDATE - 11 April 2026: due to mechanical deterioration this PC has been retired from active duty. The OS with all software and files has been migrated to my System Seven in 'Other systems' to carry on as my general purpose 'main machine'.
  • At a glance

    Windows 11 ProIntel® Core™ i5-520M8GB(integrated graphics) Intel HD Graphics
    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.
    Upgraded to 25H2 by Enablement Package.

    Also running Insider Dev, and Canary builds and Windows 10 as native boot .vhdx.
  • My SYSTEM THREE is a Dell Latitude 5410, i7-10610U, 32GB RAM, 512GB NVMe ssd, supported device running Windows 11 Pro.

    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, 1TB NVMe ssd, supported device running Windows 11 Pro, plus Insider Beta, Dev, and Canary builds (and a few others) as a native boot .vhdx.

    My SYSTEM SIX is a Dell Latitude 5550, Core Ultra 7 165H, 64GB RAM, 1TB NVMe SSD, supported device, Windows 11 Pro 24H2, Hyper-V host machine. Updated to 25H2 on 30th September 2025.

    My SYSTEM SEVEN is a Lenovo Thinkpad T580, Intel Core i7-8650U, 16GB RAM, 512GB NVMe SSD + 2nd 512GB NVMe SSD, a supported device for Windows 11. This is my current general purpose 'main machine'. The installed Windows 11 Home from my System One has been migrated to this machine.
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 My Computer

At a glance

Windows 7
OS
Windows 7

My Computer My Computer

At a glance

Windows 11
OS
Windows 11

My Computer My Computer

At a glance

Windows 11 27965Intel i7 7700 @4.0ghz64gb DDR4Radeon RX 5500 XT
OS
Windows 11 27965
Computer type
PC/Desktop
CPU
Intel i7 7700 @4.0ghz
Memory
64gb DDR4
Graphics Card(s)
Radeon RX 5500 XT
Sound Card
Topping D50s
Hard Drives
NVMe
PSU
Corsair
Keyboard
Stelseries G6v2
Mouse
Zowie EC2
Other Info
https://www.youtube.com/shoober420

Latest Support Threads

Back
Top Bottom