Fix: Windows 10 Fails to Set NumLock State at Login

Written by

in

You can manage the NumLock state automatically using PowerShell through two main strategies: permanently enforcing it at startup via the Windows Registry, or dynamically enforcing it during an active session using a continuous script.

Strategy 1: Enable NumLock Permanently at Startup (Registry Method)

Windows controls the default boot state of NumLock through specific registry keys. You can use PowerShell to update these keys to 2 (the code that forces NumLock ON) so it stays enabled every time the machine boots up. For the Login Screen (All Users)

To ensure NumLock is turned on before anyone even logs into the PC, run this command in a PowerShell terminal opened as an Administrator: powershell

Set-ItemProperty -Path ‘Registry::HKU.DEFAULT\Control Panel\Keyboard’ -Name “InitialKeyboardIndicators” -Value “2” Use code with caution. For the Currently Logged-in User

To enforce it for your specific Windows profile after logging in, use this command: powershell

Set-ItemProperty -Path ‘HKCU:\Control Panel\Keyboard\’ -Name “InitialKeyboardIndicators” -Value “2” Use code with caution.

Note: If you have “Fast Startup” enabled in Windows, it may occasionally override these settings. If NumLock still boots to an OFF state, you may need to disable Fast Startup in your power options.

Strategy 2: Dynamically Force NumLock to Stay “ON” (Live Toggle)

If your keyboard or a specific software application frequently switches NumLock off during your workflow, you can run a script that actively checks the lock status and forces it back on.

Because PowerShell treats the native [console]::NumberLock property as read-only, you have to pair it with a WScript.Shell COM Object to simulate an actual keypress event if it detects that NumLock is disabled. The Persistent Loop Script

This script checks the status of your NumLock key every 2 seconds. If it finds it turned off, it programmatically hits the NumLock key to turn it back on: powershell

\(wsh = New-Object -ComObject WScript.Shell while(\)true) { if ([console]::NumberLock -eq \(false) { \)wsh.SendKeys(‘{NUMLOCK}’) } Start-Sleep -Seconds 2 } Use code with caution. Automated Wake-from-Sleep Fix

Windows often resets the NumLock state when waking up from modern sleep or hibernation modes. Instead of running a script endlessly in the background, you can save the conditional logic to a file (e.g., SetNumlock.ps1): PowerShell: Toggle “Num Lock” on and off. – Stack Overflow

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *