How to tell if application exists

CoachBarker

Well-known member
Joined
Jul 26, 2007
Messages
133
Programming Experience
1-3
In a vb.net application I need to see if an application exists and if it is running on the current machine. The application I am creating is a modified remote desk top but I need to see if the VPN.exe exists and if it is running. I can launch the VPN from my applicaion but I have no idea how to detect it.

Any help or getting pointed in the right direction would be greatly appreciated.

Thanks
CoachBarker
 
Hi CoachBarker. How about using the Process class to detect if the application is running? Then if it is, you can perform further actions such as closing it.
 
I need to check and see if the application is installed first, if it isn't the user needs to go out to a web page and get the application and install it. Then I guess I would need to make sure it is running before they proceed on. This application is a modified version of remote desktop and the application they need to have installed is a VPN.


Can you provide an example as to how I would use the Process class to check and see if the application is running after they install it.

Thanks
Coach Barker
 
VB.NET:
        Dim p As Process = Process.GetCurrentProcess
        For Each p In Process.GetProcesses

            Console.WriteLine(p.ProcessName)

        Next
        Console.ReadLine()

There's the little Console Application I just made. What you're going to want to do is check and see if your processes name equals the current process being selected in the loop.

Here's the revised Console Application that will check to see if "firefox" is running.

VB.NET:
        Dim p As Process = Process.GetCurrentProcess
        For Each p In Process.GetProcesses
            If p.ProcessName = "firefox" Then
                Console.WriteLine("FireFox was FOUND!")
                Exit For
            Else
                Console.WriteLine(p.ProcessName)
            End If
        Next
        Console.ReadLine()
 
Now I am assuming that the running process names are case sensitive, and I had to convert this over to be used in Windows form project.
Thanks for the help
Coach Barker
 
how about having the application write a line in the registry.

if it already exists, cancel installation... or whatever other function you need it to do.
 
Back
Top