How to Detect a Running Application in VB
Detecting if an application is running in Visual Basic (VB) is important if you want to start, stop or communicate with other processes running in memory. You can use the "Process" class to retrieve a list of all the running processes. You can also search for any processes with a specific name. Once you have a list of processes you can loop through the names, displaying each one to see what is running.
Instructions
-
-
1
Open the VB source file in an editor such as Microsoft Visual Basic.
-
2
Retrieve a list of all running processes and store them to an array by adding the following code in your function:
Dim allProcesses As Process() = Process.GetProcesses()
-
-
3
Detect any running processes with a specified name and store them to an array by adding the code:
Dim myProcess As Process() = Process.GetProcessesByName("application_name")
Replace "application_name" with the name of the application.
-
4
Display a list of all the processes with a "for each" loop by adding the code:
For Each pro As Process In allProcesses
Console.WriteLine("Name: " + pro.ProcessName)
Next pro
-
5
Save the VB file, compile and run the program to view the application list.
-
1