Menu

 

Thoughts on Software Engineering

Forcing Windows to Hibernate

I usually use my home machine (running Windows 2003) from my office through Remote desktop. Sometimes in the evenings I want to hibernate it but the hibernation fails if I have used the machine remotely even if all remote connections are closed. I think this is a bug but I am not sure.

In the event log I see this message: “A request to suspend power was
denied by winlogon.exe”. This means that Windows intentionally does not want to hibernate because it thinks some remote users are still connected (which is not true).

I found two solutions to this problem:

1) Instead of using Start –> Shut Down –> Hibernate, use this command from the console:

shutdown /f /h

2) Compile and use this C# code to force Hibernation programmatically:

using System;
using System.Windows.Forms;

public class ForceWindowsHibernate
{
static void Main()
{
Application.SetSuspendState(PowerState.Hibernate, true, false);
}
}
Previews (3,577), Views (265), Comments (0)

RSS feed for comments on this post. TrackBack URL

LEAVE A COMMENT