簡體   English   中英

如何在C#中使用任務欄啟動Windows資源管理器

[英]How to start windows explorer with taskbar in c#

我需要更新外殼dll,並確保未使用它,我正在使用taskkill / F /IMexplorer.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();
    }
}

如果要替換正在使用的文件,則始終可以重命名現有文件,並使用現有名稱旁邊的原始名稱復制新版本。

然后是Windows API調用(名稱使我無所適從),該調用使您可以計划重新啟動時刪除重命名的文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM