gpt4 book ai didi

c# - 使用 C# 执行卸载

转载 作者:行者123 更新时间:2023-12-04 02:09:44 24 4
gpt4 key购买 nike

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

有没有办法通过 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com