Sleep shortcut in win7

4

5

Possible Duplicate:
What is the command to use to put your computer to sleep (not hibernate)?

When I try to create a sleep shortcut in windows 7 x64 using this code:

C:\Windows\System32\rundll32.exe Powrprof.dll,SetSuspendState Sleep
C:\Windows\System32\rundll32.exe Powrprof.dll,SetSuspendState
C:\Windows\System32\rundll32.exe Powrprof.dll,SetSuspendState 0.1.0

Then Windows hibernates instead of going to sleep.

I don't want to turn off hibernate as I do still want to be able to use it.

How do I make this work to make my computer go to sleep?

Fuj1tsu

Posted 2011-09-03T17:19:15.743

Reputation: 41

Question was closed 2011-09-03T19:46:47.940

Answers

17

Do not call these functions from rundll32. They were not designed to, and if you do, you are basically passing garbage as arguments.

You can use PsShutdown to suspend the computer (psshutdown -d) or write a tiny program of your own (someone already did1).


1 Compiled version.

user1686

Posted 2011-09-03T17:19:15.743

Reputation: 283 655

How do you tell that a function was not designed for Rundll32? – Aaron Thoma – 2012-06-20T19:10:55.633

1

@accolade: You read its documentation. The compatible functions have a very specific signature (HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow), and usually their documentation explicitly mentions rundll32. All other functions are not compatible.

– user1686 – 2012-06-20T21:20:04.947

@grawity: Thanks! How did you find the documentation for Powrprof.dll,SetSuspendState? (I had no success with two quick googlings.) – Aaron Thoma – 2012-06-22T00:29:53.830

1

@accolade: Search for the function name only, and it'll usually be the first or second result. (The DLL name is not part of normal usage; this is probably why you found no results with it.) Since it is part of Windows, adding the msdn keyword may help as well.

– user1686 – 2012-07-22T22:54:47.963