2016-04-12 63 views
0

有很多程序的,所以如果我知道它的GUID值如何卸載使用msiexec.exe的從C#如何使用MSIEXEC與程序GUID傳遞用C#參數傳遞給卸載程序

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

    } 
+2

如果您只需要調用msiexec的正確方法,那麼這不是真正的C#問題,是嗎?它是'msiexec/x {guid}'https://support.microsoft.com/en-us/kb/296067 – hometoast

+0

我想用c#調用msiecec併發送卸載值作爲參數 – toorroot

+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(); 
相關問題