Home > DotNet > How to identify a process is running using asp.net

How to identify a process is running using asp.net

Function for checking any process is running

//Namespaces we need to use
using System.Diagnostics;
public bool IsProcessOpen(string name)
       //here we're going to get a list of all running processes on
       //the computer
       foreach (Process clsProcess in Process.GetProcesses()) {
              //now we're going to see if any of the running processes
              //match the currently running processes. Be sure to not
              //add the .exe to the name you provide, i.e: NOTEPAD,
              //not NOTEPAD.EXE or false is always returned even if
              //notepad is running.
              //Remember, if you have the process running more than once,
              //say IE open 4 times the loop thr way it is now will close all 4,
              //if you want it to just close the first one it finds
              //then add a return; after the Kill
              if (clsProcess.ProcessName.Contains(name))
                     //if the process is found to be running then we
                     //return a true
                     return true;
       //otherwise we return a false
       return false;

How to run application from asp.net

Process psToLaunch = new Process();
        public void LaunchProcess()
                Process psToLaunch = new Process();
                psToLaunch.StartInfo.FileName = "notepad.exe";
            catch (Exception ex)
                throw new Exception("error on LaunchProcess() : " + ex.Message);
Categories: DotNet Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: