var curId = System.Diagnostics.Process.GetCurrentProcess().Id;
bool isAppRunning = false; var name = System.Diagnostics.Process.GetCurrentProcess().ProcessName; System.Threading.Mutex mutex = new System.Threading.Mutex(true, name, out isAppRunning); if (!isAppRunning) { Log.Warning("already running. kill the running one."); foreach (var process in Process.GetProcessesByName(name)) { if (process.Id != curId) { process.Kill(); } } }