shahine.com/omar/

homepage | Send mail to the author(s) contact

yet another Microsoft blogger

# Friday, December 29, 2006

Put your PC to sleep from the command line

I was looking for a way to put my PC to sleep from the command line (and found one). Why? Cause my new keyboard (the Microsoft Natural Ergo Keyboard 4000) doesn't have a sleep button and I wanted to set the 5th customized key to do that but all it can do is launch an application. So I set it to Run:

rundll32 powrprof.dll,SetSuspendState

and Voila.

Does anyone know of a similar command that will invoke the User Screen under Fast User Switching? The following command simply locks the computer. It's then an extra step to get to the user selection screen on vista. The reason I ask is that it's to much of a pain to go to the vista start menu to switch users.

rundll32.exe user32.dll,LockWorkStation

update: well that was fast, an anonymous commenter let me know that running tsdiscon.exe will switch users and bring you back to the logon screen. Acording to Windows this command line app "Disconnects a terminal session.".

 

Friday, December 29, 2006 11:25:51 PM (Pacific Standard Time, UTC-08:00)
What's the prob with [Windows Key] + L to lock and switch to user-selection screen?
Saturday, December 30, 2006 12:29:36 AM (Pacific Standard Time, UTC-08:00)
Because on Vista it's one more step to get from the Locked screen to the Screen where you can pick a user and logon.

Basically I want to invoke Switch User from my account directly to the screen where the next person can select a logon.
Saturday, December 30, 2006 12:46:49 AM (Pacific Standard Time, UTC-08:00)
tsdiscon.exe
Anon
Saturday, December 30, 2006 1:20:16 AM (Pacific Standard Time, UTC-08:00)
Wow, thanks anon!
Saturday, December 30, 2006 11:35:34 AM (Pacific Standard Time, UTC-08:00)
Beware that you should not use rundll32 to call LockWorkstation:

http://blogs.msdn.com/oldnewthing/archive/2004/01/15/58973.aspx
Brad C.
Friday, January 12, 2007 1:00:16 PM (Pacific Standard Time, UTC-08:00)
Regarding the sleep command, when I load this into the keyboard setup software, it rejects it because it doesn't have a file association. How did you manage to get this to work? Did you associate it with ".dll"?

The above message couldn't have been a better match to my exact situation.

Thanks for whatever feedback you can give.

madoke
madoke
Monday, December 24, 2007 1:41:23 AM (Pacific Standard Time, UTC-08:00)
look for sleep.exe by Greg Wittmeyer on google. it lets you do exactly what you are asking.

hope it helps.
anon
Monday, December 24, 2007 7:24:32 AM (Pacific Standard Time, UTC-08:00)
sleep.exe worked like a charm,THANK YOU...
Alex
Tuesday, May 20, 2008 10:07:42 PM (Pacific Daylight Time, UTC-07:00)
use the sleep command on a test computer apart of a private network but on another machine run a sniffer. what is sent to google.ca right after its run?
i cant figure it out. i know its not google toolbar since i killed it ages ago.
confuzzled
Saturday, July 19, 2008 1:15:36 AM (Pacific Daylight Time, UTC-07:00)
You did not mention how exactly you assigned the action to a key. Was it some registry fix like the one below, or something nicer?

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\AppKey\15]
"ShellExecute"="rundll32 powrprof.dll,SetSuspendState"
PM
Comments are closed.