【发布时间】:2016-04-12 16:45:45
【问题描述】:
有很多程序,所以如果我知道它的 guid 值,我如何使用 c# 中的 msiexec.exe 进行卸载
public void msi(string path)
{
//get msiexec.exe /X{GUID} from path
int slash = path.IndexOf(@"/");
//get the substring as /I{GUID}
String value = path.Substring(slash, (path.Length) - slash);
MessageBox.Show(value);
Process process = new Process();
process.StartInfo.FileName = @"msiexec.exe";
process.StartInfo.Arguments = string.Format(value);//Error is in this line
//`i just want to know how to pass the agrument to msiexec from c#`
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
process.WaitForExit();
}
【问题讨论】:
-
如果您需要的只是调用 msiexec 的正确方法,那么这并不是一个真正的 C# 问题,是吗?我是
msiexec /x {guid}support.microsoft.com/en-us/kb/296067 -
我想用 c# 调用 msiecec 并将卸载值作为参数发送
-
所以使用字符串连接!另外,请举例说明
path可能是什么。 -
请帮我解决这个问题
-
路径为 msiexec.exe /X{A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8}
标签: c# windows winforms windows-installer