0

I am from the Netherlands so apologies for my English in advance! I am doing everything that is mentioned in this post:click this link. The Powershell script works because when I go to the file and I right click it and then choose 'run with Powershell' the NUMLOCK is turned on. So far so good! However, I have tried for hours, but I can not get it to work with the task scheduler. I have tried literally everything. I have searched the web and tried all kind of things, but nothing works. When I go, in the task scheduler, to 'task status' it says that the task is being performed and under 'results' it says 'succeeded'. When I go, in the task itself, to 'history' it says 'task accomplished' with an OpCode (whatever this means?) of 2 and ID of 102. I hope I am translating all the terms correctly because I am using the Dutch version of Windows 10. In the task itself I have tried the info that i refer to but that didn't work. I now have put under 'Program / script' : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Under 'Add parameters'(optional)'I have added : C:\Users\rmansel\Documents\powershellnumlock.ps1 Under 'start in (optional)'I have added : C:\Users\rmansel\Documents Like I said, I have tried everything! From leaving 'start in' blank to putting different things in 'add parameters'. Nothing works. Like I wrote, it does start the task according to the task scheduler so I have set the triggers for the task correctly. Who can help? I would be so thankful! Best regards, Roy

  • What about formatting your text to a more readable state? – LotPings Nov 11 '18 at 12:48
  • It does not matter where you store the script. Your custom script should be in you Documents folder or a scripts folder. It's not common or recommended to place them in the default PowerShell modules, etc. locations. Now, you are not saying, what user this is set for, how that use is configured, what event Id you set this for, or other settings. Remember this can be impacted by the hardware vendor as well. – postanote Nov 12 '18 at 1:49
0

The localization of your OS is not the issue, well, I don't know / use Dutch, so....

Anyway, as long as your task schedule is set this way:

General Tab Run only when user is loggerd on

Trigger Tab Begin the Task One an event Basic Log: System Source: Kernel-Power Event ID: 42 Enabled true

Action tab Program or script = powershell Add additional arguments = -noprofile -file d:\scripts\SetNumlock.ps1

The script only needs to contain one line

# Set Numlock
(New-Object -ComObject WScript.Shell).SendKeys('{NUMLOCK}')

You could have made this a .vbs file as well, with this content

set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{NUMLOCK}"

With this change to the

Action tab Program or script = d:\scripts\SetNumlock.vbs Add additional arguments =

I fully tested both of these on my LP70 laptop. So, I know they work. Yet, as I stated in my comment, you laptop hardware can be specific and cause issues with success depending on which you use and what that hardware vendor has in place.

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.