diff --git a/Auto Restart Process/Auto Restart Process/Auto Restart.cs b/Auto Restart Process/Auto Restart Process/Auto Restart.cs index 5f98471..efd53b8 100644 --- a/Auto Restart Process/Auto Restart Process/Auto Restart.cs +++ b/Auto Restart Process/Auto Restart Process/Auto Restart.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Drawing; using System.IO; +using System.Linq; using System.Security.Principal; using System.Threading; using System.Windows.Forms; @@ -332,8 +333,7 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve { if (TimePassed.ElapsedMilliseconds >= (long)numericUpDown1.Value) { - var Processes = Process.GetProcessesByName((Path.GetFileName(textBox1.Text) ?? "UnknownFileName") - .Replace((Path.GetExtension(textBox1.Text) ?? "UnknownExtension"), "")); + var Processes = Process.GetProcessesByName((Path.GetFileName(textBox1.Text) ?? "UnknownFileName").Replace((Path.GetExtension(textBox1.Text) ?? "UnknownExtension"), "")).Where(o => Path.GetDirectoryName(o?.MainModule?.FileName) == Path.GetDirectoryName(textBox1.Text)).ToArray(); if (Processes.Length > 0) { @@ -368,6 +368,7 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve { HungTimePassed.Reset(); Proc.Kill(); + Log("Process Killed - Failed To Respond!"); break; } }