问题
I'm trying to make a simple application in C# that allows me to kill and enable explorer.exe. I need such program so that I can play Age of Empires 2 properly, because it does not like explorer.exe for some reason (I believe it has to do with Aero). So I made two buttons, one that enables explorer.exe and the other one disables it. Killing explorer.exe went ok, but enabling didn't.
I read on a few sites that you have to use the Process.Start();
to start a process. So I made Process.Start("explorer.exe");
. After killing explorer.exe, it executed the previous line but instead of having my taskbar back, it opened 'Libraries' only without giving my taskbar back. I also tried Process.Start("explorer.exe", "-p");
(I saw it somewhere), but that opened 'My Documents'.
What can I do so it starts the process explorer.exe so that I have the things like the taskbar back? I can still launch it properly with Command Prompt/Task Manager/Run.
回答1:
Solution in that topic:
foreach(Process p in Process.GetProcesses())
{
try
{
// Compare it with "explorer".
if(p.MainModule.ModuleName.Contains("explorer") == true)
{
p.Kill();
}
}
catch(Exception e)
{
// Do some exception handling here.
}
// Restart explorer.
Process.Start("explorer.exe");
}
Give that a shot.
来源:https://stackoverflow.com/questions/4279293/starting-explorer-exe-isnt-working-properly-in-c-sharp