【发布时间】:2016-04-24 17:47:18
【问题描述】:
我需要更新我的 shell dll 并确保它没有被使用,我正在使用 taskkill /F /IM explorer.exe 命令杀死当前的 Windows 资源管理器进程。
但是当我尝试再次启动资源管理器时它不会带回任务栏,我会搜索不同的解决方案来带回任务栏,但它们的问题是它可以在 Windows 8.1、10 但在 Windows 7 64 位上运行,不知何故,它没有开始,而且也是随机的(有时它确实开始了)。
以下是我尝试过的解决方案:
解决方案 1:
Process.Start(Path.GetDirectoryName(Environment.SystemDirectory) + "\\Explorer.exe");
解决方案 2:
RegistryKey localMachine = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
RegistryKey regKey = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
regKey.SetValue("Shell", "explorer.exe", RegistryValueKind.String);
regKey.Close();
Process.Start(Environment.SystemDirectory + "\\..\\explorer.exe");
解决方案 3:
var ProcessStartInfo = new ProcessStartInfo();
string anyCommand = "%systemroot%\\sysnative\\cmd.exe /c start /B explorer.exe";
ProcessStartInfo.UseShellExecute = false;
ProcessStartInfo.WorkingDirectory = System.IO.Path.Combine(System.IO.Path.GetPathRoot(Environment.SystemDirectory), "Windows\\System32");
ProcessStartInfo.FileName = System.IO.Path.Combine(System.IO.Path.GetPathRoot(Environment.SystemDirectory), "Windows\\System32\\cmd.exe");
//ProcessStartInfo.Verb = "runas";
ProcessStartInfo.Arguments = "/c " + anyCommand;
ProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
using (var exeProcess = Process.Start(ProcessStartInfo))
{
if (exeProcess != null)
{
exeProcess.WaitForExit();
}
}
【问题讨论】: