What I want to do is to kill the explorer.exe main process (which will result in killing the Windows gui programatically and then open the gui again. I can achieve that by manually killing and then starting the process through taskmanager, but I can't figure out how to do kill the main explorer process from a wpf visual C# program. Also, I tried killing it from taskmanager and then starting the windows gui again by:
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "explorer.exe",
Arguments = "",
UseShellExecute = true,
CreateNoWindow = true
}
};
proc.Start();
but it only starts a new explorer window, not the windows gui. Can someone help me to kill the win gui and start it again with some code, please?
I finally managed to find out the solution: killing the explorer.exe by getting the process and using Kill() only restarted the gui. To completely shut it down, use
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "taskkill.exe",
Arguments = "/F /IM explorer.exe",
UseShellExecute = true,
CreateNoWindow = true
}
};
proc.Start();