Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get hibernate status [closed]

Tags:

powershell

cmd

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.

EDIT

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.

like image 727
majkinetor Avatar asked Jan 13 '17 16:01

majkinetor


2 Answers

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"
like image 22
aschipfl Avatar answered Nov 18 '22 23:11

aschipfl


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")
like image 121
BenH Avatar answered Nov 19 '22 00:11

BenH