Batch File Caps Lock Num Lock -

powershell.exe -Command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{NUMLOCK}')" Ensuring a Specific State (IF Logic)

powershell.exe -Command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"

Windows Batch (.bat) files cannot natively control or check the status of or Num Lock because the CMD language lacks built-in commands for hardware state . To achieve this, a batch file must "spawn" a script using PowerShell or VBScript . Toggling via PowerShell (Recommended)

powershell.exe -Command "IF ([console]::CapsLock -eq 'False') { ... }" Super User

You can call a one-line PowerShell command from within your batch file to toggle or force a specific state.

powershell.exe -Command "IF ([console]::NumberLock -eq 'False') { ... }" Super User

0 Comments

Leave a reply

Copyright Herb & Hedgerow Ltd. 2012-2026 All Rights Reserved. Terms & Conditions | Privacy Policy | Earnings Disclaimer Herb & Hedgerow Ltd is a company registered in England and Wales. Registered number: 07957310. Registered office: Wadebridge House, 16 Wadebridge Square, Poundbury, Dorchester, Dorset DT1 3AQ, UK. Please do not post anything to this address.

CONTACT US

We love receiving your emails. We try to respond to all messages within 2 working days, but are often much faster!

Sending

Log in with your credentials

Forgot your details?