Created
July 20, 2012 09:22
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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