Skip to content

Commit

Permalink
Update Auto Restart.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
MistressPlague authored Dec 11, 2022
1 parent 62b8e6f commit e005ca6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Auto Restart Process/Auto Restart Process/Auto Restart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -368,6 +368,7 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve
{
HungTimePassed.Reset();
Proc.Kill();
Log("Process Killed - Failed To Respond!");
break;
}
}
Expand Down

0 comments on commit e005ca6

Please sign in to comment.