c# - 使用 C# 执行卸载

标签 c# uninstallation

我一直在网上寻找这个,但找不到。

有没有办法通过 C# 触发卸载程序(从“程序和功能”屏幕)?还是出于安全目的,这被 Windows 阻止了?

最佳答案

您可以使用 msiexec.exe .您可以简单地卸载带有产品代码 的应用程序。使用命令,您可以设置是在卸载过程中显示 UI 还是静默卸载,

string UninstallCommandString = "/x {0}/qn";

  • /qn:设置用户界面级别:无
  • /qb:设置用户界面级别:Basic UI
  • /qr: 设置用户界面级别:Reduced UI
  • /qf:设置用户界面级别:Full UI(默认)

C#代码

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();

关于c# - 使用 C# 执行卸载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19559930/

相关文章:

c# - Xmlserializer 不序列化基类成员

inno-setup - 关于在 Inno Setup 脚本的 [UninstallRun] 部分中使用 RunOnceId 的说明

android - 如何在我的应用程序被卸载之前显示 Activity (Android)

eclipse - 在 OSX 下卸载 Eclipse?

installation - 为什么要在 Macintosh 应用程序中使用软件包安装程序?

c# - 如何在从整数数组创建的列表中使用 ANY?

c# - 我的 monodroid UI 元素(Button、TextView ...)中的枚举需要一个 .Net 包

C# 如何从拉伸(stretch)位图/图片框获取像素

postgresql - 无法重新安装 PostgreSQL,因为 Windows 认为它​​仍然已安装

c# - 如何以编程方式检查 WP8 设备是否有前置摄像头