我正在使用HTA尝试使用WindowsInstaller.Installer作为ActiveXObject安装产品。使用过去使用的相同HTA模型,安装尝试会抛出错误:“Msi API错误:InstallProduct,PackagePath,PropertyValues”。
我在Windows Vista和Server 2003上都试过这个,但没有成功。两者都使用IE8,所以我认为它可能是某种ActiveX兼容性问题。然后我在IE6中对它进行了测试并遇到了同样的问题 - 但是,我们过去曾多次将这种格式用于HTA并取得了成功。我试图从两台计算机上的管理员帐户安装,并且MSI本身按预期执行。
到目前为止,我已尝试过以下内容:
以下是失败的方法/上下文:
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时才发现相关问题(显然已经修复过)。有什么想法吗?
答案 0 :(得分:1)
我的安装设置存在类似的问题。
我使用了VBScript并启动了MSI
Set sh = CreateObject("WScript.Shell")
l_command = "%SystemRoot%\System32\msiexec.exe /i """ & sh.CurrentDirectory & "\" & p_file & """"
sh.Exec l_command