如何使用带有程序guid的msiexec卸载程序以使用c#传递参数

时间:2016-04-12 16:45:46

标签: c# windows winforms msiexec

有很多程序所以如果我知道它的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();

    }

1 个答案:

答案 0 :(得分:0)

感谢大家对此代码的支持

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