我無法使用ConfigureProduct進行卸載,無聲地運行。我有以下幾點:使用Microsoft.Deployment.WindowsInstaller.Installer.ConfigureProduct以靜默方式卸載?
using Microsoft.Deployment.WindowsInstaller;
Installer.ConfigureProduct(productCode, 0, InstallState.Absent, "/q");
根據一些早期的帖子「/ Q」應該工作,除了每次我運行代碼時出現以下情況例外。
"Invalid command line argument. Consult the Windows Installer SDK for detailed command line help."
注意,「/ Q」使用msiexec.exe的,但我想做到這一點使用Microsoft.Deployment.WindowsInstaller時不工作。
我也曾嘗試UI設置爲靜音下列要求:
Installer.SetInternalUI(InstallUIOptions.Silent);
Installer.ConfigureProduct(productCode, 0, InstallState.Absent, "");
但後來我得到以下異常:
"Fatal error during installation."
從消息據我瞭解,SetInternalUI是安裝,而不是的卸載但不確定。
我正在使用版本爲2.0.50727的WiX 3.9 R2安裝中的DLL。
任何幫助表示讚賞。謝謝!
編輯:我在「ConfigureProduct」方法中對「commandLine」參數的註釋看起來更接近一些。
// commandLine:
// Specifies the command line property settings. This should be a list of the
// format Property=Setting Property=Setting.
所以基本上沒有,你不能傳遞「/ Q」,「/ L」,或其他任何不在表「屬性=設置」。答案中鏈接的參考文章中的例子似乎是錯誤的。 (或其它版本之間的改變,但我對此表示懷疑。)
是的,這就是我得到致命錯誤的原因。我從一個提升的命令提示符啓動了程序,它工作。有沒有簡單的方法使用Microsoft.Deployment.WindowsInstaller API以提升模式運行ConfigureProduct? – user2958211