Is it possible to get hibernation status using shell ?
I am using powercfg.exe
to enable/disable it and there doesn't seem to be any way to get the status, even using /Q (query).
I also tried to base that on existence of %SystemDrive%\hiberfil.sys
but that requires admin rights.
Current solution is outdated:
From version 1809 the registry setting “HibernateEnabled” was renamed “HibernateEnabledDefault”. If you use cmd (powercfg.exe /hibernate off), it is created in addition to the “HibernateEnabledDefault” parameter “HibernateEnabled” with all of the control circuits of the supply.
Setting registry didn't have any effect for me since this version. I had to go to Control Panel\Hardware and Sound\Power Options\System Settings
to enable it, after that powercfg options worked again. If both HibernateEnabled
and HibernateEnabledDefault
are deleted, I still got Hibernate option active.
Here is an alternative for cmd, based on the registry query by BenH's answer:
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Power" /v "HibernateEnabled"
To capture the result and store it into a variable, use this:
for /F "delims=" %V in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Power" /v "HibernateEnabled"') do set "Hibernate=%V"
You could check the registry key:
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Power -name HibernateEnabled
Or remotely using .Net and Remote Registry:
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "ExampleComputer")
$RegKey = $Reg.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Power")
$RegKey.GetValue("HibernateEnabled")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With