Scheduled Tasks - Sleep and Wake

Only thing I can think of is tying in a task to run when a certain event is logged in eventviewer, not sure of any other way to do it. I haven't really used scheduled tasks on server 2008 though, it might be worth having a poke about.
 
Hi Soundsgood,

So the code is

Code:
Option Explicit

Dim wmiPowerManagementEvent, objProcess
Const cntEventEnteringSuspend = 4

Set wmiPowerManagementEvent = GetObject("winmgmts:").ExecNotificationQuery("Select * from Win32_PowerManagementEvent")
Do
   If wmiPowerManagementEvent.NextEvent.EventType = cntEventEnteringSuspend Then
	For Each objProcess in GetObject("winmgmts:").ExecQuery("select * from Win32_Process where name='ehshell.exe'")
	  objProcess.Terminate(0)
        Next
   End If
Loop

I presume I alter eshell.exe to the process I want to end? If I save this to startup, does it close every time I go to standby? What format is it?

If I want to open the same process, or the exe is for example c:/program/program.exe, what would I alter this to? Does the startup folder work on standby resume? ie can i save a shortcut in the startup folder and will that make it reopen?

Thanks for any help :)
 
If you find Event ID 42 from Kernel-Power [Sleep] and Event ID 1 from Power-Troubleshooter [Wake], you can create a Scheduled Task that runs when those events are logged. In the Event Viewer, clicking an entry should provide an option on the right to Attach Task to this Event.

Might be easier than trying to get the script to work when you don't know what you're changing. :)
 
If you find Event ID 42 from Kernel-Power [Sleep] and Event ID 1 from Power-Troubleshooter [Wake], you can create a Scheduled Task that runs when those events are logged. In the Event Viewer, clicking an entry should provide an option on the right to Attach Task to this Event.

Might be easier than trying to get the script to work when you don't know what you're changing. :)

Excellent, will have a look when I get it powered back up :)

I noticed in the scheduler that there is a close program option, but didn't see one to open program, any ideas? (This is just from memory)
 
Back
Top Bottom