howmanyareRunning("notepad.exe")
Function howmanyareRunning(iprocessName)
Dim objWMIService, objProcess, colProcess, strComputer, processName, instances
strComputer = "."
instances = 0
processName = iprocessName '"firefox.exe"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcess
If objProcess.Name = processName Then instances = instances + 1
Next
If processName = "wscript.exe" Then
If instances = 1 Then
WScript.Echo "There is no other VBScript running except this one!"
Else
WScript.Echo "There are currently " & "(" & instances _
& ") " & "VBScript" & " Instances running!"
End If
Else
WScript.Echo "There are currently " & "(" & instances & ") " & _
"""" & processName & """" & " Instances running!"
End If
End Function
instances = 0
processName = iprocessName '"firefox.exe"
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
("Select * from Win32_Process")
If objProcess.Name = processName Then instances = instances + 1
Next
If instances = 1 Then
WScript.Echo "There is no other VBScript running except this one!"
Else
WScript.Echo "There are currently " & "(" & instances _
& ") " & "VBScript" & " Instances running!"
End If
Else
WScript.Echo "There are currently " & "(" & instances & ") " & _
"""" & processName & """" & " Instances running!"
End If
OUTPUT
=======
No comments:
Post a Comment