Hello @Philip Gross ,
powercfg /hibernate is still available, but it doesn't do what you want it to do.
What it does:
This command enables the hibernation feature on the system, it configures the system to allow hibernation. Without this, the hibernate option is unavailable.
Which means it should be on, not off the way your command says.
Secondly, it should be run once, not always running it if you want to hibernate your computer.
Your second command:
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
This command should work, if hibernation is enabled, however Microsoft doesn’t officially encourage using rundll32.exe commands for power management in modern systems, as it can behave inconsistently across versions.
What I recommend:
There are 2 options, depending on what you want.
Hibernate:
Open your command prompt as an admin and run:
powercfg /h on
Then, Create a New Shortcut: Right-click on your desktop. Select New > Shortcut, in the place where you need to input the command, use:
shutdown /h /t 0
/ t 0 determins the time in secons, change it as you please, the default is 30.
Then, click next and give it a name like Hibernate or something.
Sleep:
To the best of my knowledge, there is no way you can put your computer to sleep with the powercfg command. So, we now turn to PowerShell.
Kindly note: creating a shortcut with this command is not possible, but there is a work around. So do the following:
- Create a *.ps1 file, where * is the name of your script. For example: sleep.ps1.
- Open your file with notepad, or whatever text editor you wish, and put this in it:
Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Application]::SetSuspendState('Suspend', $false, $false)
- Save it and exit.
But if you want to create a shortcut, do the following after creating your script:
- Right-click on your desktop or desired location.
- Select New > Shortcut.
- In the shortcut location field, enter:
powershell -ExecutionPolicy Bypass -File "C:\path\to\SleepScript.ps1"
Execution Policy: The -ExecutionPolicy Bypass ensures the script runs without policy restrictions.
Replace C:\path\to\SleepScript.ps1 with the full path to your script.
4. Click Next, name the shortcut Sleep or whatever, and click Finish.
Now, you can run it whenever you want.
I hope this helps, and don't forget to drop a comment if you are not clear, or still need help.