Windows – Emulate a keyboard button via the Command Line

cmd.execommand linenumlockpowershellwindows

My keyboard doesn't have a Num Lock key, and none of the registry edits work for some reason.

Can I use the Command Prompt or PowerShell on Windows 10 to "press" a key? I'm looking for something like press pgup to press the Page Up Key in the Command Prompt or PowerShell, but for Num Lock.

Best Answer

How do I toggle numlock status using PowerShell.

Use the following script:

$wsh = New-Object -ComObject WScript.Shell

Source StackOverflow answer PowerShell: Toggle “Num Lock” on and off. by Andy Arismendi

As pointed out by ABashore in his comment this can be shortened as follows: