5

我正在使用 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 模式下运行

这是失败的方法/上下文:

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 时才发现一个相关问题(这显然已得到修复)。有任何想法吗?

4

1 回答 1

1

我的安装集也有类似的问题。

我使用了 VBScript 并启动了 MSI

Set sh = CreateObject("WScript.Shell")
l_command =  "%SystemRoot%\System32\msiexec.exe /i """ & sh.CurrentDirectory & "\" & p_file  & """"
sh.Exec l_command
于 2009-11-10T09:18:21.683 回答