Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: How can I set a scheduled task to minimize open windows before sleep?

18 Jul 2010   #11

Win7 / XP

I'm on a different PC now but I'll look at the idle options - seems like I did look at that before.

The other option I'm thinking is adding "sleep" into the script you gave me. That way I can pin the script/executable onto the taskbar and when my wife wants to put the pc to sleep, she can click on the executable instead of the windows icon.

You don't have any idea as to how to modify the script so that it will minimize the windows and ALSO put the pc to sleep, do you? I'm going to do some googling as well.

Thanks again for your help!

My System SpecsSystem Spec
18 Jul 2010   #12

Win 7 Ultimate 32bit

I was also thinking that you can try creating a Task for Idle time that calls this file to run it instead of using Power Management.

Also, this should work on PowerShell 2.0 on XP SP3, Vista and 7.
But has only been tested on 7.

Ok, I think, according to this...
"How To Put the System into hibernation or Standby from Run menu"

If hibernation is enabled, then the system will hibernate (this can be a better thing)
If it is disabled, the system will sleep.
That is, if I am reading right. Anyway....

Let me know if this works for you or not.

Download the MinWin&Suspend.exe file and run it,,, that's all you have to do.

The following 2 files are extracted and run...

start /min powershell -executionpolicy remotesigned -file "%userprofile%\desktop\MinWin&Suspend.ps1"
and then

$shell = new-object -comobject shell.application
Start-Sleep -s 5
rundll32 powrprof.dll,SetSuspendState
MD5: BED1E28250F6B2407EE9F3647541573B
My System SpecsSystem Spec
21 Jul 2010   #13

Win7 / XP

Thanks Tepid. Haven't had a chance to try it but will let you know what happens. I really appreciate the help and suggestions!

PS - right on with the tags on the bottom of your messages!
My System SpecsSystem Spec

03 Dec 2013   #14

Windows 7 Home Premium 64 bit

[QUOTE=Tepid;845071]This should work....

Set shell = wscript.CreateObject("Shell.Application")
paste that to a text file and then name it whatever.vbs
Create a task that calls the file,, should work.

Let us know if not, it may need some refining on the commands in the Task itself, to call the vbs file properly. I have not used it in 7, but it works when double clicked


I used this VBS script to create a task scheduled at a specific time. I need to tear myself away from my computer to go to bed so I set it up to minimized all windows every 1 minute - the triggers repeat every five minutes for an hour, but I set up five triggers at 9:40, 9:41, 9:42 etc.

I really appreciate the script - I need something that is annoying but that I can still work through for a few minutes if I have to finish up.
My System SpecsSystem Spec
15 Dec 2013   #15

win7 64bit Ult. using: XP Mode, in English or Español, SUA, Bitlocker

Possibly alternate suggestion:

As a safeguard, disable the sleep button in the startup menu. Tutorial: Sleep : Disable in Shut Down Menu

Or possibly a better way to disable the sleep button is to go to the Power Options screen | Change Plan Settings | Change Advanced Power Settings (lower left). There will be a little dialog that pops up. Scroll down to 'Power Buttons and lid', and adjust the 'Sleep Button Action' accordingly - Do Nothing.

The computer does not have to sleep immediately before she leaves it, I'm thinking(??) For example, maybe you can have the task scheduler start a daily task- to run a script posted above in this thread at a certain time.... possibly at 12:00 or whatever. The script will minimize all windows (show desktop), then it puts the computer to sleep.

ETA: Kudos to the above posters who suggest commands to put the computer to sleep. Apparently it's not that easy of a task. Something you would think is simple at first glance, isn't.

Note: Then if you have time, try to find a command that will stop all network traffic before it puts the computer to sleep. These days, they have USBs that are available for charging even when the computer is sleeping. This means that to me that the computer is NOT sleeping like it used to... It's still 'on' in a sense. You get the picture.
My System SpecsSystem Spec
16 Dec 2013   #16

win7 64bit Ult. using: XP Mode, in English or Español, SUA, Bitlocker

You may need two jobs in Task Scheduler - one after the other. Here is how to make two little programs. One to show desktop, and the other to put the computer into sleep mode:


Show the Desktop, type these file lines into a somename.scf file:


..that will show the desktop / minimize all windows.



Then to sleep, use this in a .bat file. Follow the next three steps to create this.

1) Make a somename.bat file.

2) paste the next three lines into it... save

Echo On
Rundll32.exe Powrprof.dll,SetSuspendState Sleep

3) run it.

Need to add the Sleep argument/word at the end of the line above.

Some users say that it puts their computer into hibernate mode, not sleep. May have to disable Hibernation. Worked for me though.

Hope this helps.
My System SpecsSystem Spec

 How can I set a scheduled task to minimize open windows before sleep?

Thread Tools

Similar help and support threads
Thread Forum
The scheduled task are executed even if Windows is started in safe mod
Hi In Windows 7 SP1, the scheduled tasks, run at system startup, are executed even if Windows is started in safe mode? Thanks Bye
General Discussion
Scheduled Task history indicates task completed successfully but....
Hi, New here. I'm using a Scheduled Task to fire a very simple bat file that pulls, compresses and pushes a set of files to a different network directory. The bat file runs fine manually. On a networked desktop I have set up the task to run at about 5am est (waking the machine), as highest...
Performance & Maintenance
Scheduled Task / Batch Code on Windows Server 2008 R2 SP1
I have some processes that I need to stop and restart each morning. In order to do this, I've created 2 scheduled tasks inside Task Scheduler: 1.) Stop Foobar (Both Environments) - Triggers @ 6:45 AM Every Day 2.) Start Foobar (Both Environments) - Triggers @ 6:48 AM Every Day Both tasks...
windows 7 scheduled task remote access
I recently upgraded my system to Windows 7 and I am unable to access scheduled taks on my remote servers. Before when I was running off win XP i had no problem with this. But now, even when opening up share folders on all my servers, i dont see the scheduled task folder; however, when i check on a...
Network & Sharing
wish I could minimize ALL when multiple windows open in same program
I really like aspects of the new taskbar, especially pinning program icons to it. I always would open my main program's in the same order so they would be in the same place on taskbar, but if I had to close one and reopen... oh well. so 7 fixed that problem, BUT. If I have multiple windows...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 10:45.
Twitter Facebook Google+