Launching a script after 10 minutes of inactivity?
-
Wednesday, November 12, 2008 5:24 PMHello all. I'm a newbie here on this forum, although I have been lurking in the background for some time now.
I am wondering if anyone knows of a way to launch a script after 10 minutes of inactivity, similar to the way a screensaver kicks in.
I'd also like it to close if there is any activity at all. So basically, I'm looking for a screensaver-type of script that will not interfere with the WIndows screensaver and will close if the mouse is moved, key is pressed, etc.- Edited by xjbone Wednesday, November 12, 2008 5:37 PM
Answers
-
Thursday, November 13, 2008 8:09 AMModerator
I have, on my PC, the screensaver Mystify.scr which is triggered when my computer has been idle for 15 minutes. I have a "watchdog" service (actually) script that checks when this screensaver is triggered and if so, deletes all BAK files from my D: drive. The script should exit once the computer becomes active (when the screensaver process exits). Here's my script:
1 sHost = "." 2 Set oWMIService = GetObject("winmgmts:\\" & sHost & "\root\cimv2") 3 Set oEventSource = oWMIService.ExecNotificationQuery _ 4 ("SELECT * FROM __InstanceOperationEvent" & _ 5 " WITHIN 10 WHERE TargetInstance ISA 'Win32_Process'") 6 Do While True 7 Set oEventObject = oEventSource.NextEvent() 8 If oEventObject.TargetInstance.Name = "Mystify.scr" Then 9 Set colItems = oWMIService.ExecQuery _ 10 ("Select * from Win32_OperatingSystem") 11 For Each oItem in colItems 12 DelFiles("D:") 13 Next 14 End If 15 Loop 16 17 Sub DelFiles(strDrv) 18 Set colFiles = oWMIService.ExecQuery _ 19 ("Select * from CIM_DataFile Where Drive = '" & _ 20 strDrv & "' and Extension = 'bak'") 21 For Each objFile in colFiles 22 objFile.Delete 23 Next 24 End Sub Regards,
Salvador Manaois III
C|EH MCSE MCSA MCITP|Server/Enterprise Admin
Bytes & Badz : http://badzmanaois.blogspot.com- Marked As Answer by IamMredMicrosoft Employee, Owner Thursday, January 07, 2010 12:05 AM

