user11605008
user11605008

Reputation:

Check if Running a process string VB.Net

For example, if the process will be, MozillaFirefox.exe, how do I do if I put: p = Process.GetProcessesByName("Mozilla") and find the process "MozillaFirefox" just one example. consider the first 5 letters: Mozii and find out if there is a process run that starts with "Mozii" Thanks. so new versions Process that begin with 1.7 or 1.8 or 2.1 after name are easier to find.

Dim p() As Process

Private Sub CheckIfRunning()
    p = Process.GetProcessesByName("Mozii")
    If p.Count > 0 Then
        ' Process is running
    Else
        ' Process is not running
    End If
End Sub

Upvotes: 0

Views: 508

Answers (1)

Idle_Mind
Idle_Mind

Reputation: 39132

You could filter the return of all processes from Process.GetProcesses() using something like this:

p = Process.GetProcesses.Where(Function(ps) ps.ProcessName.ToLower.StartsWith("mozii")).ToArray

Upvotes: 1

Related Questions