I am trying to achieve killing process when screensaver is active, but something is wrong:
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objEventSource = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 10 WHERE TargetInstance ISA 'Win32_Process'")
Do While True
Set objEventObject = objEventSource.NextEvent()
If Right(objEventObject.TargetInstance.Name, 4) = ".scr" Then
Dim oShell : Set oShell = CreateObject("WScript.Shell")
oShell.Run "taskkill /im thunderbird.exe", , True
End If
Loop