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.


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:

| improve this answer | |
  • It doesnt appear that you need to define "wsh" to do what he needs. I was able to simply toggle the NUMLOCK with just a single line. – ABashore Oct 27 '15 at 16:11
  • @ABashore Cool. I've upvoted your answer – DavidPostill Oct 27 '15 at 16:13

Here's a powershell line that will toggle your NUMLOCK. I've tested this and it works on my Logitech K120 USB keyboard.


Here's a list of the other SendKey codes.

If you need to send the keystroke to an interactive application, more code will be needed.

| improve this answer | |


Without creating temporary files. The 'loop' was shown only so that you could open a notebook for output. Remove it after.

    @echo off
            ::------------begin main code------------
            set command=new ActiveXObject('WScript.Shell').SendKeys('WoW{ENTER}{ENTER}');
            for /f "delims=" %%i in ('mshta "javascript:%command%close(new ActiveXObject('Scripting.FileSystemObject'));"') do set
            ::-------------end main code-------------
            timeout /t 1 /nobreak >nul
        goto :loop
| improve this answer | |
  • would you mind updating your answer to give a little more information as to what’s going on in that script? – Jaketr00 May 27 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.