我在互联网上寻找了这个问题,但是找不到答案。
有没有办法通过C#触发卸载程序(从“程序和功能”屏幕)?或者这被Windows为安全目的所阻止了?
我在互联网上寻找了这个问题,但是找不到答案。
有没有办法通过C#触发卸载程序(从“程序和功能”屏幕)?或者这被Windows为安全目的所阻止了?
产品代码
简单卸载它。使用命令,您可以设置在卸载过程中是否显示UI或使其成为静默卸载,
string UninstallCommandString = "/x {0} /qn";
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();
System.Diagnostics.Process.Start("/path/to/uninstall.exe", "arguments for uninstaller if needed, else don't bother with this arg");
这个方法快速而且简单,/应该/会起作用的。希望可以帮到你。
编辑- 我刚意识到你想从添加或删除软件屏幕上进行操作。不过我还是把这个留在这里吧,我的错。