Free Tool – Suspend from the command line

by Steve Wiseman on September 22, 2009 · 5 comments

in BAT Files, Tools, Utility, Windows

I have a system task schedule that wakes up my system at night, runs a few backup processes…and then shuts the computer down.

What I really wanted it to do was to suspend, or hibernate. That way I can get back into my computer quick when I come back in the morning.

After searching around, I found that this little VB Script command can be used to suspend a computer:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "RunDll32.exe powrprof.dll,SetSuspendState"

Unfortunately this does not work on all versions of Windows. For my task, I wanted something I could use on anything from Windows 2000, to the 64 bit version of Windows 7.

After many fruitless searches on Google, I had the IntelliAdmin team build one for me.

It is called System Suspend, and you can download it from here: SystemSuspend.exe

If you run the program with no options, it will immediately suspend the computer. There are two optional arguments you can use when calling it:

/Hibernate:[TRUE|FALSE] – Defaults to false. If you set Hibernate to true the computer will totally power off and save the state to disk. If Hibernate is set to false, then the system will go into a low power state that will allow you to resume quickly

/Force:[TRUE|FALSE]- Applications are notified of the suspend/hibernate by default. If you set the force option to true, then it will skip this step and perform the action immediately

We have tested it on Windows 2000, XP, 2003, Vista, Windows 7, and 2008 – including 64 bit versions…and it works great on all of them.

{ 5 comments… read them below or add one }

Rob September 22, 2009 at 1:46 pm

“shutdown.exe /h” is built-in going back to XP, and was in the Win2000 Resource Kit before that.

Steve Wiseman September 22, 2009 at 2:10 pm

Doh! Did not know that.

Still, it is not a total loss…since that would mean I would need to download and install the resource kit to get the functionality I want (for 2000)

In addition…we eventually will take a tool like this and include it with Network Administrator 3.0 (We want it to be compatible with Win 2000), and I don’t think the MS license will allow for that.

Yea – I had to come up with some excuse so I don’t look like a total fool for missing that one ;)

Rob September 22, 2009 at 2:41 pm

Heh, didn’t mean to embarrass. :7 Good point, tho: you probably couldn’t redistribute shutdown.exe (esp. in a commercial product).

P. Benjamin September 27, 2009 at 4:02 am

Hi,

thx for this nixe tip and tool.

In my opinion you just forget a step : checking if the computer can andlhe hibernate mode.

When i tried SystemSuspend nothing happend because the hibernate option wasn’t avaible (don’t ask me why, i have no clue).

I just had to do a “powercfg /h on” and it’s ok now. Maybe you should do this check when ppl launch your tool :)

(By the way, i tried it on Windows 2008 Server Enterprise).

Cya :)

Steve Wiseman September 29, 2009 at 10:05 pm

Just tried it on a system where it is not allowed…and sure enough no error is displayed

Not much we can do about it tho – The api call within windows (SetSystemPowerState) is returning success. We would need to see an error from this call to know there was a problem.

Leave a Comment

Previous post:

Next post: