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

timber

New member
Member
Local time
3:08 PM
Messages
55
Location
California
I would like to set up a scheduled task that will minimize all open windows when I choose sleep or hibernate from the start menu.

For some reason, if I don't minimize any open windows before entering "sleep" mode, I get screen freezes and video card errors upon awakening. I would just like to have Task Scheduler automatically minimize open windows in case my wife forgets to do so.

The machine is a Toshiba A300 laptop that I've upgraded to Windows 7 32 bit from Vista.
 

My Computer My Computer

At a glance

Win7 / XP
OS
Win7 / XP
A workaround?

Try disabling Windows Aero and see if that resolves the issue.

If you want to minimize everything before going to standby... well, maybe you can take the habit of pressing Windowskey+M every time you leave your computer (you can reverse it with Windowskey+M+shift).
 

My Computer My Computer

At a glance

Windows 71.66 Ghz Intel Atom N2801 GB (upgrading to 2GB)
Computer Manufacturer/Model Number
Asus EEE PC 1000HE
OS
Windows 7
CPU
1.66 Ghz Intel Atom N280
Motherboard
Asus
Memory
1 GB (upgrading to 2GB)
Hard Drives
140 GB
ST9160310AS ATA
I tried turning off Aero (but will try again). At this point I've tried everything including 3 installs of Win7, all sorts of new (and old) video drivers, power settings, and so on. Minimizing windows before sleeping is the only thing that has worked.

The reason I want to automate the windows minimization is that it is my wife's PC and she doesn't always remember to do this. If it were just me, it would not be a problem.

There must be some sort of scheduled task that I could set up to minimize windows whenever sleep or hibernate is invoked.
 

My Computer My Computer

At a glance

Win7 / XP
OS
Win7 / XP
This should work....

Code:
Set shell = wscript.CreateObject("Shell.Application")
Shell.MinimizeAll
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 found this somewhere a long time ago.
I have used it before,, but not in a while. I haven't had a need for it in some time.
 

My Computer My Computer

At a glance

Win 7 Ultimate 32bitC2D E6600 2.4Ghz4G Kingston KHX5400D2EVGA GTX 570 HD SC (012-P3-1573-KR)
Computer Manufacturer/Model Number
Self Built
OS
Win 7 Ultimate 32bit
CPU
C2D E6600 2.4Ghz
Motherboard
Intel D965WH
Memory
4G Kingston KHX5400D2
Graphics Card(s)
EVGA GTX 570 HD SC (012-P3-1573-KR)
Sound Card
On-Board
Monitor(s) Displays
Samsung 226BW
Screen Resolution
1680 x 1050
Hard Drives
2 x 250 Seagate Barracuda
2 x 500 Seagate Barracuda (Raid1)
PSU
Corsair TX750W
Case
In-Win C589
Cooling
Stock Intel Cooling
Hi Tepid - script works great - but now was wondering if you or anyone knows how to set it up under task scheduler so that it gets invoked upon sleep. I don't see an obvious task name like "sleep" listed as an option under "triggers", though presumably there are other things that happen before sleep that I could use as a trigger instead.

Thanks much!

Tim
 

My Computer My Computer

At a glance

Win7 / XP
OS
Win7 / XP
If I am not mistaken, windows generates a kernel power event with the ID 42 when entering sleep. So what you can try is, in task scheduler, under triggers, select "On Event", then specify 42.
 

My Computer My Computer

At a glance

Windows 7 x64 pro/ Windows 7 x86 Pro/ XP SP3 x86
Computer Manufacturer/Model Number
Too many to describe...
OS
Windows 7 x64 pro/ Windows 7 x86 Pro/ XP SP3 x86
Yeah I might try the Event ID 42

The Log is System
Source is Kernel-Power
Event ID is 42

I would also set the Stop task if it runs longer than 30 min just incase something causes it to run away

or

Under Conditions Tab,, you can try using Idle options.
 

My Computer My Computer

At a glance

Win 7 Ultimate 32bitC2D E6600 2.4Ghz4G Kingston KHX5400D2EVGA GTX 570 HD SC (012-P3-1573-KR)
Computer Manufacturer/Model Number
Self Built
OS
Win 7 Ultimate 32bit
CPU
C2D E6600 2.4Ghz
Motherboard
Intel D965WH
Memory
4G Kingston KHX5400D2
Graphics Card(s)
EVGA GTX 570 HD SC (012-P3-1573-KR)
Sound Card
On-Board
Monitor(s) Displays
Samsung 226BW
Screen Resolution
1680 x 1050
Hard Drives
2 x 250 Seagate Barracuda
2 x 500 Seagate Barracuda (Raid1)
PSU
Corsair TX750W
Case
In-Win C589
Cooling
Stock Intel Cooling
Thanks much Tepid & Bill - I will try your suggestions.
 

My Computer My Computer

At a glance

Win7 / XP
OS
Win7 / XP
Hmm - doesn't seem to be working. I think the event 42 doesn't happen until it is too late for the task to be executed.
 

My Computer My Computer

At a glance

Win7 / XP
OS
Win7 / XP
Did you try the Idle options under the Conditions Tab?
 

My Computer My Computer

At a glance

Win 7 Ultimate 32bitC2D E6600 2.4Ghz4G Kingston KHX5400D2EVGA GTX 570 HD SC (012-P3-1573-KR)
Computer Manufacturer/Model Number
Self Built
OS
Win 7 Ultimate 32bit
CPU
C2D E6600 2.4Ghz
Motherboard
Intel D965WH
Memory
4G Kingston KHX5400D2
Graphics Card(s)
EVGA GTX 570 HD SC (012-P3-1573-KR)
Sound Card
On-Board
Monitor(s) Displays
Samsung 226BW
Screen Resolution
1680 x 1050
Hard Drives
2 x 250 Seagate Barracuda
2 x 500 Seagate Barracuda (Raid1)
PSU
Corsair TX750W
Case
In-Win C589
Cooling
Stock Intel Cooling
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 Computer My Computer

At a glance

Win7 / XP
OS
Win7 / XP
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.cmd
Code:
start /min powershell -executionpolicy remotesigned -file "%userprofile%\desktop\MinWin&Suspend.ps1"
and then

MinWin&Suspend.ps1
Code:
$shell = new-object -comobject shell.application
$shell.minimizeall()
Start-Sleep -s 5
rundll32 powrprof.dll,SetSuspendState
*****************************
MD5: BED1E28250F6B2407EE9F3647541573B
 
Last edited:

My Computer My Computer

At a glance

Win 7 Ultimate 32bitC2D E6600 2.4Ghz4G Kingston KHX5400D2EVGA GTX 570 HD SC (012-P3-1573-KR)
Computer Manufacturer/Model Number
Self Built
OS
Win 7 Ultimate 32bit
CPU
C2D E6600 2.4Ghz
Motherboard
Intel D965WH
Memory
4G Kingston KHX5400D2
Graphics Card(s)
EVGA GTX 570 HD SC (012-P3-1573-KR)
Sound Card
On-Board
Monitor(s) Displays
Samsung 226BW
Screen Resolution
1680 x 1050
Hard Drives
2 x 250 Seagate Barracuda
2 x 500 Seagate Barracuda (Raid1)
PSU
Corsair TX750W
Case
In-Win C589
Cooling
Stock Intel Cooling
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 Computer My Computer

At a glance

Win7 / XP
OS
Win7 / XP
This should work....

Code:
Set shell = wscript.CreateObject("Shell.Application")
Shell.MinimizeAll
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 Computer My Computer

At a glance

Windows 7 Home Premium 64 bitIntel Pentium G6950 Processor (3MB Cache, 2.8...4 GB Dual Channel DDR3 SDRAM at 1066MHz (4 DI...Intel HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Inspiron Desktop 580 MiniTower
OS
Windows 7 Home Premium 64 bit
CPU
Intel Pentium G6950 Processor (3MB Cache, 2.80GHz)
Motherboard
ACPI x64
Memory
4 GB Dual Channel DDR3 SDRAM at 1066MHz (4 DIMMs)
Graphics Card(s)
Intel HD Graphics
Hard Drives
WDC WD5003AZEX-00K1GAO ATA Device
Antivirus
Microsoft Essentials
Browser
IE 9.0.22
Possibly alternate suggestion:

As a safeguard, disable the sleep button in the startup menu. Tutorial: http://www.sevenforums.com/tutorials/85194-sleep-disable-shut-down-menu.html

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 Computer My Computer

At a glance

win7 64bit Ult. using: XP Mode, in English or...8GB - included when purchased.
Computer type
Laptop
OS
win7 64bit Ult. using: XP Mode, in English or Español, SUA, Bitlocker
Memory
8GB - included when purchased.
Monitor(s) Displays
two: Laptop: 1366x768 and HP 1024x768.
Hard Drives
1: 750GB
Keyboard
Second: PS2 connection Compaq kboard, used w/adapter cable.
Mouse
USB mouse.
Antivirus
MS Security Essentials
Other Info
XP Mode Apps used: VC6 C++ and MSDN help as virtual PC apps - one for ea. monitor.
Tri-boot machine. Has Ubuntu 12.04 and Win 8.0 on as well - both used seldomly.
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:
-------------

From http://www.wikihow.com/Make-the-Show-Desktop-Icon-in-Windows-Quick-Launch-Toolbar

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

[Shell]
Command=2IconFile=explorer.
exe,3
[Taskbar]
Command=ToggleDesktop

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

==========================================

From: http://answers.microsoft.com/en-us/...tcut-for/4e57f536-50a8-4942-a84a-290b3dea1ffb

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
Exit

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.
 
Last edited:

My Computer My Computer

At a glance

win7 64bit Ult. using: XP Mode, in English or...8GB - included when purchased.
Computer type
Laptop
OS
win7 64bit Ult. using: XP Mode, in English or Español, SUA, Bitlocker
Memory
8GB - included when purchased.
Monitor(s) Displays
two: Laptop: 1366x768 and HP 1024x768.
Hard Drives
1: 750GB
Keyboard
Second: PS2 connection Compaq kboard, used w/adapter cable.
Mouse
USB mouse.
Antivirus
MS Security Essentials
Other Info
XP Mode Apps used: VC6 C++ and MSDN help as virtual PC apps - one for ea. monitor.
Tri-boot machine. Has Ubuntu 12.04 and Win 8.0 on as well - both used seldomly.
Back
Top