【发布时间】:2013-11-02 19:20:51
【问题描述】:
我一直在互联网上寻找这个,但我找不到它。
有没有办法通过 C# 触发卸载程序(从程序和功能屏幕)?还是出于安全目的而被 Windows 阻止?
【问题讨论】:
标签: c# uninstallation
我一直在互联网上寻找这个,但我找不到它。
有没有办法通过 C# 触发卸载程序(从程序和功能屏幕)?还是出于安全目的而被 Windows 阻止?
【问题讨论】:
标签: c# uninstallation
您可以使用msiexec.exe。您可以使用product code 简单地卸载应用程序。使用命令可以设置卸载时显示 UI 还是静默卸载,
string UninstallCommandString = "/x {0} /qn";
C# code
string UninstallCommandString = "/x {0} /qn";
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
process.StartInfo = startInfo;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardError = true;
startInfo.FileName = "msiexec.exe";
startInfo.Arguments = string.Format(UninstallCommandString, "Product Code");
process.Start();
【讨论】:
product code?
您可以使用 system.diagnostics 为卸载程序调用可执行文件。
类似下面的东西应该可以解决问题:
System.Diagnostics.Process.Start("/path/to/uninstall.exe", "arguments for uninstaller if needed, else don't bother with this arg");
它又快又脏,/应该/工作。希望对您有所帮助。
edit- 刚刚意识到您想从添加删除软件屏幕执行此操作。无论如何我都会把它留在这里,但我的错误。
【讨论】: