Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI win32_process events end email 1

Status
Not open for further replies.

hbaake

Programmer
Jun 25, 2001
19
NL
Hi!

I'm using WMI to start several processes on a remote machine, but would like to be nofified by email when a process dies.

I know this should be possible using event filtering, but documentation on this topic is hard to find :-(.

Is there anybody who has more info (or even some sample code)?

Thanks in advance,

Hugo.
 
I think this should work as long as it run on the pc the process are running on. I havn't gotten it to work on a remote pc yet. You will also need to install SMTP for the email to work. I think this will only work on 2k or xp version of windows. I found most of this script on Microsofts site so if it doesn'w work exactly like you want try looking there.

strComputer = "."
processname = "'netscp.exe'"
loopvar = 1
do until loopvar = 0
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = " & processname)
If colProcesses.Count = 0 Then
dim objEmail
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "test@test.com"
objEmail.To = "test@test.com"
objEmail.Subject = "test"
objEmail.Textbody = "test" & time
objEmail.Send
loopvar = 0
Else
wscript.sleep 900000
End If
loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top