簡體   English   中英

System.Process.Start-運行MSI問題

[英]System.Process.Start - running msi problem

當我嘗試在vb應用程序中使用System.Process.Start(“ test.msi”)運行MSI時,出現以下錯誤。

無法打開安裝包。 與應用程序供應商聯系...

雙擊並嘗試使用文本文件和exe文件嘗試System.Process.Start時,MSI文件工作正常,它們僅工作於MSI問題

文件。 運行遠景。 還嘗試了XP但沒有運氣

謝謝

如果您的msi包含setup.exe,請運行它。 否則,請使用以下代碼:

Process p = new Process();
p.StartInfo.FileName = "msiexec";
p.StartInfo.Arguments = "/i PathToYour.msi";
p.Start();

(從這里開始: MSI不在C#中運行

之所以需要這樣做,是因為當您執行System.Process.Start("file.txt")它將可以正常工作,因為它正在調用notepad.exe %1 (對文本文件有效),但是因為msiexec具有必需的參數(選項),所以msiexec %1不適用於msi。

您可以通過在命令行上嘗試msiexec file.msi來自己進行測試-它會給您以下有用的小信息:

沒有選項的MSI

有同樣的問題。 問題在於聲明msi的路徑。 您需要用雙引號引起來。

代替

p.StartInfo.Arguments = "/i PathToYour.msi"

嘗試

p.StartInfo.Arguments = "/i ""PathToYour.msi"""

為了幫助查明問題,請嘗試從代碼中運行其他一些.exe,例如notepad.exe。

System.Process.Start("notepad.exe")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM