Home » Microsoft Operations Manager 2005 » Count number of instances

Count number of instances

This script checks if notepad.exe is running more that 4 times. If it is running more than 4 times a event is generated. You can then collect those event and get an alert in operators console.


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objShell = CreateObject("Wscript.Shell")
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'notepad.exe'")
If colProcesses.Count < 4 Then Const EVENT_WARNING = 2 Set objShell = CreateObject("Wscript.Shell") objShell.LogEvent EVENT_WARNING, _ "There are less then 4 instances of notepad.exe running" End If


1 Comment

Comments are closed.