【问题标题】:How to start windows explorer with taskbar in c#如何在 C# 中使用任务栏启动 Windows 资源管理器
【发布时间】: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();
    }
}

【问题讨论】:

    标签: c# .net wpf windows-7


    【解决方案1】:

    如果您想替换正在使用的文件,您可以随时重命名现有文件并将新版本复制到现有文件旁边的原始名称。

    然后有一个 Windows API 调用(名字让我忘记了),它允许您安排在重新启动时删除重命名的文件。

    【讨论】:

    猜你喜欢
    • 2020-05-21
    • 2011-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多