Skip to content

Instantly share code, notes, and snippets.

@fresky
Created July 20, 2012 09:22
Show Gist options
  • Save fresky/3149841 to your computer and use it in GitHub Desktop.
Save fresky/3149841 to your computer and use it in GitHub Desktop.
Check whether a process is started or not, if not, then start it in background
Regex regex = new Regex(@"app");
bool found = false;
foreach (var process in Process.GetProcesses())
{
if (regex.Match(process.ProcessName).Success)
{
found = true;
break;
}
}
if (!found)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo("app");
processStartInfo.CreateNoWindow = true;
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(processStartInfo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment