Poser une questionPoser une question
 

QuestionLaunching a script after 10 minutes of inactivity?

  • mercredi 12 novembre 2008 17:24xjbone Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    Hello 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.

    • Modifiéxjbone mercredi 12 novembre 2008 17:36
    • Modifiéxjbone mercredi 12 novembre 2008 17:37
    •  

Toutes les réponses

  • jeudi 13 novembre 2008 08:09Salvador Manaois IIIModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     A du code

    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