On Error Resume Next 'Objective: To monitor the Process on a machine 'Created By :MAK 'Date Written: Nov 10, 2004 Set objArgs = WScript.Arguments ProcessName= objArgs(0) instance= objArgs(1) LogFile=objArgs(2) ServerName=objArgs(3) Set FSO = CreateObject("Scripting.FileSystemObject") if FSO.fileexist(LogFile) = True then Set FSOA = FSO.openTextFile(LogFile,8) end if if FSO.fileexist(LogFile) = False then Set FSOA = FSO.openTextFile(LogFile,2,True) end if count=0 strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & ServerName & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_Process",,48) For Each objItem in colItems if objItem.Name =ProcessName then count=count+1 'Wscript.Echo "Name: " & objItem.Name end if Next If cstr(count) < instance then string1 = ": ServerName =" & Servername & ": ProcessName =" & ProcessName & " : Number of given instances to monitor is =" & instance & " : Number of running instance " & count & ": Date=" & now() FSOA.Writeline string1 end if If cstr(count) = instance then string1 = ": ServerName =" & Servername & ": ProcessName =" & ProcessName & " : Number of given instances to monitor is =" & instance & " : Number of running instance " & count & ": Date=" & now() FSOA.Writeline string1 end if