【问题标题】:How to Uninstall a program using msiexec with program guid to pass an argument with c# [duplicate]如何使用带有程序 guid 的 msiexec 卸载程序以使用 c# 传递参数 [重复]
【发布时间】: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


【解决方案1】:

感谢大家对这段代码的支持

        Process p = new Process();
        p.StartInfo.FileName = "msiexec.exe";
        //The argument that you want to give
        p.StartInfo.Arguments = "/X{0784DF00-13E1-40D1-8BC4-E081AD2DA509}";
        p.Start(); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-30
    • 2018-07-18
    • 1970-01-01
    • 2015-08-31
    • 1970-01-01
    • 2011-09-20
    • 1970-01-01
    • 2017-08-09
    相关资源
    最近更新 更多