Sleep Shortcut

ByLine
How to Create a Sleep Shortcut on the Desktop in Vista
Synopsis
This will show you how to create a Sleep shortcut used to put your computer into sleep (not hibernate) mode when clicked on.
How to Create a Sleep Shortcut on the Desktop in Vista

information   Information
This will show you how to create a Sleep shortcut used to put your computer into sleep (not hibernate) mode when clicked on.
Note   Note
If you would like to place this shortcut in Quick Launch, then see Option Three in this link for how: How to Use Quick Launch in Vista
Tip   Tip
If you would like to create a keyboard shortcut for this shortcut, then see: How to Create a Keyboard Shortcut for a Program in Vista
warning   Warning
This shortcut will perform the same action set for the Start Menu power button when pressed. You will need to make sure that the Start Menu power button is set for Sleep if you want this shortcut to put your computer to sleep when used. For how, see: How to Change the Power Button Settings for the Start Menu and Case in Vista



Here's How:
1. Click on the download button below to download the Sleep Shortcut.zip file.​
2. Click on Save and save it to the Desktop.​
download

3. Right click on the Sleep Shortcut.zip (on desktop) and click on Open.​
4. Click on Allow for UAC prompt.​
5. Select and extract both the Sleep shortcut and Sleep Shortcut Folder to the desktop.​
6. Open a Windows Explorer window and navigate to C:\Program Files.​
NOTE: Not in the C:\Programs Files (x86) folder for 64 bit Vista users.
7. Right click on the Sleep Shortcut folder (on desktop) and click Cut, then right click on a empty space in the Windows Explorer window (step 6) and click Paste.
Note   Note
The Sleep Shortcut folder has the Sleep.vbs scipt file in it. This is the contents of this vbs script:
Code:
Dim objShell[/INDENT][/INDENT]
[INDENT][INDENT]Set objShell = CreateObject("Shell.Application")[/INDENT][/INDENT]
[INDENT][INDENT]objShell.ShutdownWindows[/INDENT][/INDENT]
[INDENT][INDENT]set objShell = nothing[/INDENT][/INDENT]
[INDENT][INDENT]Set WshShell = CreateObject("WScript.Shell")[/INDENT][/INDENT]
[INDENT][INDENT]WshShell.SendKeys "{Enter}"[/INDENT][/INDENT]
[INDENT][INDENT]Set WshShell = Nothing
A) Click on Continue in the Destination Folder Access Denied prompt.​
B) Click on Continue in the UAC Prompt.​

8. Put the Sleep shortcut (on desktop) where you would like for easy use. (See the NOTE at the top of the tutorial)
NOTE: If you would like to use a icon of your own instead, then see: How to Change a Shortcut Folder or File Icon in Vista for how.​
9. You can now delete the Sleep Shortcut.zip (on desktop) file if you like.​
warning   Warning
This shortcut will perform the same action set for the Start Menu power button when pressed. You will need to make sure that the Start Menu power button is set for Sleep if you want this shortcut to put your computer to sleep when used. For how, see: How to Change the Power Button Settings for the Start Menu and Case in Vista
warning   Warning


That's it,
Shawn

CREDIT TO: sidney1st for providing a better way to do this with a VBS script.
Thank you.


 
Last edited by a moderator:
Shawn Brink

Comments

Hello Adam, and welcome to Vista Forums.

Interesting, what settings do you have set in the task so that I can give it a try with them?
 
Hey all..

Question about this old thread. I've got the Sleep shortcut on my desktop and it works fine when I just double-click it. Goes right to sleep.

However, if I have Task Scheduler run it at a particular time, it pops up the regular logoff prompt with the pulldown menu (Sleep, Shut Down, etc.) and waits for my response.

Any ideas on that? It happens on both of my Vista PCs. Both power buttons are configured to sleep.

Thanks..

Adam
Hi Adam,

Set Task Scheduler to execute the command directly instead of using the shortcut: rundll32 powrprof.dll, SetSuspendState

It shouldn't have any problems executing the command directly, Its just how Task Scheduler handles shortcut/script execution from its protected user environment ;)

Let us know if using the command instead of the shortcut allows your machine to sleep without waiting for confirmation :)

Steven
 
Not sure what all the chatter is about. But this VBS is NOT a Sleep script. It is Shutdown, pure and simple. :confused:

But there are other more simple ways of creating a shortcut; there is little here that is really new. I just create a shortcut on my desktop, and apply the following as the command:

rundll32.exe PowrProf.dll, SetSuspendState Sleep

The icon can be taken from PoweProf.dll, just like this supposed Sleep Shortcut does. You just have to navigate to the DLL and apply it yourself. :sleepy:
 
Hello Jay, and welcome to Vista Forums.

Funny, that the VBS in the tutorial puts my system into Sleep mode and not shut down. Have you tried it? :confused:

That command will work for sleep, but only if you turn off hibernate first. ;)

Hibernation - Enable or Disable
 
Hello,
I downloaded Brink's shortcut and I found out that when my start menu power button is set for shutdown, I can see when I open the script, it shows an "are you sure" box, and it shows a box of what you want your computer to do; it said "shutdown" (by default). After that, I set the power button to hibernate; the box said "hibernate" (by default). Finally, after that, I set the power button to sleep; the box said "sleep" (by default). In no way does the script duplicate the case power button if you are wondering (for Vista Home Premium x64 users). Then I thought of the question: can the script be edited in such a way so that it can only set the computer to sleep and not follow the start menu power button without disabling the hibernate feature?
 
Last edited:
Hi, sorry to revive an old thread, but the script doesn't work the way it was intended for me, it pops up the confirmation box, and I don't know how to avoid that ??
 
Hello gn2, and welcome to Vista Forums.

Which confirmation dialog does it give you? (ex: UAC, Open File - Security, etc...)

Does this happen when you run only the script, or the shortcut?
 
It pops up the dialogue to choose which type of action to complete with the shut down button, Sleep is the one shown, and all you have to do is click the "Ok" or whatever the exact word is, but its still another click that shouldn't be necessary...

I've tried right clicking on the shortcut to choose "Run As Administrator" in the Properties page to allow it to work without confirmation of my choice, but it still pops up the choice box....and the "Run Shortcut as Administrator" option checkbox it greyed out anyway...

Also, someone referred to setting about "how Task Scheduler handles the script" ? I have no idea how to see/change that, but I would suspect that is related as when I double click the shortcut directly, instead of hitting the keyboard key assigned to the shortcut, it "Sleeps" without popping up the window....
 
It sounds like the line below is not exactly the same in your .vbs file. That the line that press Enter for you automatically instead of having to click on OK.

WshShell.SendKeys "{Enter}"



Code:
[SIZE=3]Dim objShell 

Set objShell = CreateObject("Shell.Application") 

objShell.ShutdownWindows

set objShell = nothing

Set WshShell = CreateObject("WScript.Shell")

[B]WshShell.SendKeys "{Enter}"[/B]

Set WshShell = Nothing[/SIZE]
 
Top