【问题标题】:HTA installer for MSI failingMSI 的 HTA 安装程序失败
【发布时间】:2009-10-22 23:45:21
【问题描述】:

我正在使用 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. 在 IE 中将 localhost 添加到受信任站点列表中
  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 时发现了一个相关问题(这显然已得到修复)。有什么想法吗?

【问题讨论】:

  • 您是否尝试过在 Windows 脚本主机 .wsf 文件而不是 HTA 下运行相同的脚本?如果是,结果是否相同?
  • 我已经在 XP 机器上运行了没有管理帐户的示例,它可以工作。 (只删除了"display:none;visibility:hidden;")所以它可能是Vista/2003特有的?
  • 它在 Windows 7 上对我来说似乎工作正常。您是否检查了应用程序事件日志(应该来自 MsiInstaller)中的 real 错误代码?
  • 另一件值得尝试的事情可能是启用 Windows Installer 登录您的注册表:support.microsoft.com/kb/223300

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


【解决方案1】:

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

我使用了 VBScript 并启动了 MSI

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多