Getting the count of a running process.

colmite

New member
Joined
May 29, 2007
Messages
2
Programming Experience
Beginner
Hi All,

I cant seem to find the answer to this for VB.NET and hoping some one can help me. I am looking to look at all running processes on a system and take a look at the number of times say IEXPLORE.exe is running. In my .vbs script I had a function that looks like this:

VB.NET:
sub CheckCompletion
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'monitor.exe'")

do while colProcesses.Count > 5
    Wscript.Sleep 60000
    Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'monitor.exe'")
Loop
End Sub

This way I could keep 5 monitoring sessions open at all times. If one was to quit, my main body of the script would then spawn off another version of Monitor.exe

I can not seem to find a way to do this same thing in VB.NET. Any help would be greatly appreciated..

i case it is of any interest this is what I have for imports:


VB.NET:
Imports System
Imports System.Environment
Imports System.Diagnostics
Imports System.Threading
Imports System.Data
Imports System.Data.OleDb
Imports System.Management
thanks again!
 
.Net has a Process class that you can use, you didn't find this when you searched help for "process"?
VB.NET:
Dim count As Integer = Process.GetProcessesByName("name").Length
 
Back
Top