문제

I am looking solution to monitor process or processes (visible in Task Manager) running in computer/server and on killing of same either manually or itself should generate and alert mail to specified Email IDs specially for particular task process if possible.

Please help me in same, i have tried few options but only able to list process list but not able to generate mailer on killing of service.

도움이 되었습니까?

해결책

Here is a WMI Event watcher based on the __InstanceDeletionEvent, it will tell you when the notepad.exe is closed via wscript popup and restart itself if you name it "Notepad_Emailer.vbs"

strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!" & "\\" & strComputer & "\root\cimv2")
Set objEventSource = objSWbemServices.ExecNotificationQuery( "SELECT * FROM __InstanceDeletionEvent " & "WITHIN 1 " & "WHERE TargetInstance " & "ISA 'Win32_Process' " & "AND TargetInstance.Name = 'notepad.exe'")
Set objEventObject = objEventSource.NextEvent()
set kdshell = createobject("WScript.Shell")
Wscript.Echo "NOTEPAD WAS CLOSED, REPLACE THIS LINE WITH YOUR EMAIL SCRIPT"
kdshell.Run "Notepad_Emailer.vbs",0,false

Combine this with your email snippet and you are all set.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top