Can I remap the power-button to run a script (CMD, PowerShell, AHK...) e.g. via a registry entry under HKLMiSYSTEMlCurrentControlSetiControNKeyboard LayoutiScancode Map?
Asked
Active
Viewed 60 times
1
Pingui
- 159
- 6
-
1I don't think so. For most computers, the power button just does a soft connect into the power circuitry. – John Mar 07 '23 at 14:26
-
1Short answer: No as it's a mechanical switch not a key – DavidPostill Mar 07 '23 at 14:50
-
Only by rewiring the PC, not recommended. However, you can easily create a task to run at startup: https://www.wintips.org/how-to-start-a-program-at-startup-with-task-scheduler/ – DrMoishe Pippik Mar 07 '23 at 15:04
-
@DrMoishe Pippik Interesting. Is there also something like "On shutdown"? See question: https://superuser.com/questions/1772427/task-scheduler-on-shutdown – Pingui Mar 07 '23 at 15:32
1 Answers
2
No, the power button on a computer is not connected to the computer like a keyboard key is. Technically, the operating system is not aware of the power button, it sends power on/off signals through the ACPI controller on the motherboard, which is passed to the operating system as an ACPI command. Some BIOS's allow for changing what signal is sent, like shutdown/suspend/sleep. However, this is no different than changing it at the OS level.
Keltari
- 71,875
- 26
- 179
- 229