Skip to content

Commit

Permalink
支持强制重启explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
indiff committed Apr 9, 2024
1 parent eb3099f commit acc668a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions SetHome/SetHomeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,16 +944,26 @@ private void button6_Click(object sender, EventArgs e)

private static void RestartExplorer()
{
bool KillFlag = false;
foreach (Process process in Process.GetProcessesByName("explorer"))
{
try
{
process.Kill();
KillFlag = true;
}
catch
{
KillFlag = false;
}
}

if (!KillFlag)
{
Process.Start(@"%systemroot%\taskkill.exe", @"/F /T IM explorer.exe" );
// @"/F /T /PID " + process.Id);
}

Thread.Sleep(1500);
if (Process.GetProcessesByName("explorer").Length != 0)
return;
Expand Down Expand Up @@ -1035,5 +1045,10 @@ private void rocketmq_click(object sender, EventArgs e)
UpdateEnvPath();
}
}

private void SetHomeForm_FormClosed(object sender, FormClosedEventArgs e)
{
System.Environment.Exit(1);
}
}
}

0 comments on commit acc668a

Please sign in to comment.