Enable NumLock when computer awakens from sleep mode

Solution 1:

As a workaround, I composed a PowerShell script that enables NumLock, then set up a task in the Task Scheduler to run it whenever the computer awakes from sleep mode.

  1. Using Notepad, save the following text as a .ps1 file

    if(-not [console]::NumberLock){ $w = New-Object -ComObject WScript.Shell; $w.SendKeys('{NUMLOCK}'); }

  2. If you've never run PowerShell scripts on your computer before, you'll need to change the execution policy to allow scripts to be run. Run PowerShell.exe as administrator, then type the following and hit enter:

    Set-ExecutionPolicy RemoteSigned

    That will allow you to run unsigned scripts that physically are on your computer, but prevent people from executing unsigned scripts remotely.

  3. Type "Task Scheduler" into the start menu and click on it to open the scheduled tasks library.

  4. Right click on Task Scheduler Library and choose "Create Task..."

  5. In the General tab, give the task a name like "make sure numlock is on" and then switch to the Action tab

  6. Give the task an action to "Start a Program". The program will be PowerShell.exe (you'll need to paste in the full path to the PowerShell executable) and the action should have an "Argument" of:

    -command "&'path/to/your/file.ps1'"

    ...replacing the path in single quotes with the actual path of the PS1 script you saved earlier.

    Note that you can get the full path to anything in Windows Explorer (including both PowerShell.exe and your PS1 script) by holding down shift and right-clicking on it, then choosing "Copy as path."

  7. Switch to the Triggers tab and add as many triggers to the scheduled task as desired. There are built-in triggers for "at log on," "at startup," and "at workstation unlock," but there might not be one for when it wakes up from sleep mode.

    Instead, you can set a custom trigger "on an event," meaning based on an entry in the event log (you can type "Event Viewer" into the start menu to see what events kick off when your computer awakens from sleep mode). Events based on sleep mode will probably be found in the System category under Windows Logs.

  8. Make sure there are no conditions under the Conditions tab that would prevent your task form running, such as when it is on battery power

  9. Save the task. You can right-click on it and run it to make sure it enables NumLock as desired.