diff --git a/Auto Restart Process/Auto Restart Process/Auto Restart.cs b/Auto Restart Process/Auto Restart Process/Auto Restart.cs index 4dd6ce5..98daa70 100644 --- a/Auto Restart Process/Auto Restart Process/Auto Restart.cs +++ b/Auto Restart Process/Auto Restart Process/Auto Restart.cs @@ -276,7 +276,7 @@ private void textBox1_TextChanged(object sender, EventArgs e) private void checkBox2_CheckedChanged(object sender, EventArgs e) { - RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); + var rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (rk != null) { @@ -345,11 +345,11 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve Log("Restarting!"); - ProcessStartInfo Info = new ProcessStartInfo + var Info = new ProcessStartInfo { FileName = textBox1.Text ?? "", WorkingDirectory = Path.GetDirectoryName(textBox1.Text) ?? Environment.CurrentDirectory, - Arguments = textBox2.Text.Replace("%APPDIR%", Path.GetDirectoryName(textBox1.Text) ?? Environment.CurrentDirectory).Replace("%TIME%", DateTime.Now.ToString("dd MM ss tt")), + Arguments = textBox2.Text.Replace("%APPDIR%", Path.GetDirectoryName(textBox1.Text) ?? Environment.CurrentDirectory).Replace("%TIME%", DateTime.Now.ToString("dd MM yyyy - hh mm ss tt")), CreateNoWindow = checkBox3.Checked, WindowStyle = (ProcessWindowStyle)comboBox1.SelectedIndex }; @@ -361,11 +361,14 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve AlreadyStarted: while (Proc != null && !Proc.HasExited) { - if (HungTimePassed.ElapsedMilliseconds >= numericUpDown2.Value) + if (NotRespondingPref.Checked) { - HungTimePassed.Reset(); - Proc.Kill(); - break; + if (HungTimePassed.ElapsedMilliseconds >= numericUpDown2.Value) + { + HungTimePassed.Reset(); + Proc.Kill(); + break; + } } if (Proc.HasExited) @@ -373,13 +376,16 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve break; } - if (!Proc.Responding) - { - HungTimePassed.Start(); - } - else + if (NotRespondingPref.Checked) { - HungTimePassed.Reset(); + if (!Proc.Responding) + { + HungTimePassed.Start(); + } + else + { + HungTimePassed.Reset(); + } } } @@ -389,7 +395,9 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve if (checkBox1.Checked) { - label5.Text = "Restart Count: " + RestartCount++; + RestartCount++; + + label5.Text = "Restart Count: " + RestartCount; } } }