5

我正在使用HTA嘗試使用WindowsInstaller.Installer作爲ActiveXObject安裝產品。使用過去一直使用的相同HTA模型,嘗試安裝時會拋出錯誤:「Msi API錯誤:InstallProduct,PackagePath,PropertyValues」。MSI失敗的HTA安裝程序

我在Windows Vista和Server 2003上都嘗試過這種方式,但沒有成功。兩者都使用IE8,所以我認爲這可能是某種ActiveX兼容性問題。然後我在IE6中測試了它,並遇到了同樣的問題 - 但是,過去我們幾次使用這種格式的HTA,並取得了成功。我試圖從兩臺機器上的管理員帳戶進行安裝,並且MSI本身按預期執行。

到目前爲止我曾嘗試以下:

  1. 更改文件路徑爲MSI到絕對
  2. 更改「命令行設置」(第二個參數)爲InstallProduct方法「ACTION = ADMIN」(強制管理員安裝)和‘ACTION =’在IE
  3. 更改ActiveX設置 - ‘安裝初始化和腳本的ActiveX控件未標記爲可安全執行腳本’設置爲‘提示’
  4. 添加本地主機到可信站點列表在IE
  5. 添加兼容性元標記到HTA在IE7Emulation,IE5或IE6模式

這裏運行是方法/上下文失敗:

var Software = new Array(
    new Array("..\\Software\\Product.msi", "ProductCode")); 

    function run_msi(i) 
{ 
    try 
    { 
     //Execute MSI application install on error resume next 
     var msi = new ActiveXObject("WindowsInstaller.Installer"); 
     var installer = Software[i][0]; 
     msi.UILevel = 5; // full interactive mode 
     msi.InstallProduct(installer, ""); 
    } 
    catch (e) 
    { 
     alert ("Unable to launch the Installer Package. This may be because you do not have permission to install software."); 
    } 
    // Check the install status of the MSI to ensure it is in the registry 
    RegistryKeyExists(i); 
} 

上點擊時的方法,然後調用如下

<td><span class="link" style="display: none; visibility: hidden" id="SoftwareTextTrue0" onclick="javascript:run_msi(0);">Uninstall</span> <span class="link" style="display: none; visibility: hidden" id="SoftwareTextFalse0" onclick="javascript:run_msi(0);">Install</span> </td>

我已經廣泛一派,只找到一個相關的問題時,有人在嘗試「安裝」按鈕安裝Silverlight 3(顯然已經被修復)。有任何想法嗎?

+0

您是否嘗試過運行在Windows腳本宿主的.wsf文件,而不是HTA此相同的腳本?如果是這樣,結果是一樣的嗎? – dreftymac 2009-10-30 04:38:53

+0

我已經在XP機器上運行沒有管理帳戶的示例,它可以工作。 (只刪除了''display:none; visibility:hidden;「')所以它可能對Vista/2003特別有用? – Paul 2009-11-02 12:47:42

+1

它似乎在Windows 7上正常工作。您是否檢查了_real_錯誤代碼的應用程序事件日誌(應該來自MsiInstaller)? – tyranid 2009-11-09 22:31:26

回答

1

我的安裝集有類似的問題。

我用VBScript和啓動MSI

Set sh = CreateObject("WScript.Shell") 
l_command = "%SystemRoot%\System32\msiexec.exe /i """ & sh.CurrentDirectory & "\" & p_file & """" 
sh.Exec l_command