使用C#中的System.Diagnostics.Process及其UninstallString卸载程序

本文关键字:及其 UninstallString 卸载 程序 Process Diagnostics 中的 System 使用 | 更新日期: 2023-09-27 17:58:01

Im正在使用此代码(也尝试过此代码)使用注册表中的卸载字符串卸载程序,但第一个链接的代码中有一些错误。我正在尝试修复它,但我很难弄清楚文件名中的内容和Arguments中的内容。我的UninstalString是:

rundll32.exe dfshim.dll,ShArpMaintain-ItemMan.Client.application,Culture=neutral,PublicKeyToken=4f1069eb693dc232,processorArchitecture=msil

注册表中的目录是

CurrentUser''SOFTWARE''Microsoft''Windows''CurrentVersion''Uninstall''9e648bbdf5bc3053

我遇到麻烦的部分:

            System.Diagnostics.Process FProcess = new System.Diagnostics.Process();
            FProcess.StartInfo.FileName = "rundll32.exe"; (Dont know if this is right though, but have tried various ways to write the FileName...)
            FProcess.StartInfo.Arguments = "9e648bbdf5bc3053";
            FProcess.StartInfo.UseShellExecute = false;
            FProcess.Start();
            FProcess.WaitForExit();

有了这一点,什么都不会发生。我尝试的所有其他方法都抛出了一个错误。HOw will you Cut up/Use your unistalString to uninstall that program

使用C#中的System.Diagnostics.Process及其UninstallString卸载程序

卸载字符串是全部内容,第一个可执行文件之后的所有内容都是参数,因此需要执行以下操作:

var start_info = new StartInfo() {
    FileName = "rundll32.exe",
    Arguments = "dfshim.dll,ShArpMaintain ItemMan.Client.application, Culture=neutral, PublicKeyToken=4f1069eb693dc232, processorArchitecture=msil",
    UseShellExecute = false
};
Process process = new Process(start_info);
process.Start();
process.WaitForExit();