Create Windows Hotkeys for Sleep and Shutdown
source: https://www.pcworld.com/article/2090921/how-to-create-hotkeys-for-windows-sleep-and-shutdown.html
The Power button, of course, is the one you press when you turn on your PC. You may or may not have a sleep button on your keyboard. To find out, look for a key with a crescent-moon icon. With a laptop, Sleep probably involves holding down the Fn key while you press another key. If you can’t find a Sleep key on your keyboard, check the keyboard documentation to see if there’s a way to reassign another key for that purpose. It’s possible that you simply don’t have that option.
If you need more power hotkeys (likely if you don’t have a Sleep key), you can create your own.
First, create a shortcut: Right-click an empty space on the desktop and select New>Shortcut. On the only field available on the resulting wizard, enter the appropriate command:
- Shut down:
Shutdown.exe -s -t 00
- Reboot:
Shutdown.exe -r -t 00
- Lock:
Rundll32.exe User32.dll,LockWorkStation
(and yes, that one works on 64-bit systems) - Hibernate or Sleep:
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
If the Hibernate option is turned on, that last command will hibernate the PC. Otherwise, it will put it to sleep.
To control that setting in Windows 7, click Start, type cmd
, right-click cmd.exe, and select Run as administrator. In Windows 8, go to the Search charm, type cmd
, right-click Command Prompt and select Run as administrator.
At the resulting command prompt, type powercfg -hibernate off or powercfg -hibernate on
, then press ENTER.
Now that you’ve created a shortcut, let’s turn it into a hotkey: Right-click the shortcut and select Properties. On the Shortcut tab, click the Shortcut key field. Press a key. Windows will automatically prefix it with Ctrl-Alt, lessening the likelihood of accidentally turning off your computer.
And believe me, if there's on thing you don't want to do, it's accidentally turning off your computer.