MSI的HTA安装程序失败

时间:2009-10-22 23:45:21

标签: javascript internet-explorer-8 windows-installer hta failed-installation

我正在使用HTA尝试使用WindowsInstaller.Installer作为ActiveXObject安装产品。使用过去使用的相同HTA模型,安装尝试会抛出错误:“Msi API错误:InstallProduct,PackagePath,PropertyValues”。

我在Windows Vista和Server 2003上都试过这个,但没有成功。两者都使用IE8,所以我认为它可能是某种ActiveX兼容性问题。然后我在IE6中对它进行了测试并遇到了同样的问题 - 但是,我们过去曾多次将这种格式用于HTA并取得了成功。我试图从两台计算机上的管理员帐户安装,并且MSI本身按预期执行。

到目前为止,我已尝试过以下内容:

  1. 将MSI的文件路径更改为绝对
  2. 将InstallProduct方法的“命令行设置”(第二个参数)更改为“ACTION = ADMIN”(强制管理员安装)和“ACTION = INSTALL”
  3. 在IE中更改ActiveX设置 - “将未标记为可安全编写脚本的ActiveX控件初始化并编写脚本”至“提示”
  4. 将localhost添加到IE中的受信任站点列表
  5. 向HTA添加兼容性元标记以在IE7Emulation,IE5或IE6模式下运行
  6. 以下是失败的方法/上下文:

    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>

    我广泛使用Google搜索,只有在有人试图安装Silverlight 3时才发现相关问题(显然已经修复过)。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我的安装设置存在类似的问题。

我使用了VBScript并启动了MSI

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