Wix 的自定义动作调用 vb 脚本失败 [英] Custom action of Wix failed to call vb script

查看:26
本文介绍了Wix 的自定义动作调用 vb 脚本失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在包本身中有一个 VB 脚本.我需要使用 CMD 调用它,这是调用脚本的默认方式花费太多时间,所以我尝试使用 CMD 和 CSCRIPT 调用它,但安装程序在安装时引发错误.

I have one VB script in the package itself. I need to call it using CMD, the default way of calling the script taking too much time, so I am trying to call it with CMD and CSCRIPT but the installer raises the error while installation.

我使用的以下代码未按预期工作.我搜索了很多,但没有找到解决方案.

I am using the following code which is not working as expected. I searched a lot but didn't find the solution.

<Binary Id="ServiceInstall"  SourceFile="..\..\..\AddVirDir.vbs" />

 <CustomAction Id="InstallService" BinaryKey ="ServiceInstall" 
               ExeCommand="CMD /C &quot;[#ServiceInstall]&quot;" 
               Execute="immediate" Return="check"  HideTarget="no" Impersonate="no"/>

推荐答案

服务安装 &控制:您不应使用脚本安装服务.MSI 中有非常优越的内置机制.您只需使用 ServiceInstallServiceControl WiX XML 元素并声明"应如何注册服务以及何时以及如何注册应该启动和停止服务:

Service Installation & Control: You should not install services with scripts. There are built-in mechanisms in MSI that are vastly superior. You simply use the ServiceInstall and ServiceControl WiX XML Elements and "declare" how the service should be registered and when and how the service should be started and stopped:

<Component>
   <File Source="$(var.SourceDir)\WindowsService.exe" />
   <ServiceInstall Name="MyService" ErrorControl="normal" Start="auto" Type="ownProcess" />
   <ServiceControl Id="MyService" Name="MyService" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
</Component>

看!没有自定义操作!:-) - 只是 MSI 自动魔法.无需为此使用任何自定义操作.MSI 功能齐全且可靠,前提是您的服务可执行文件按预期运行.

Look! No custom actions! :-) - Just MSI auto-magic. There is no need to use any custom actions for this. MSI is full-featured and reliable provided your service executable behaves as it is supposed to.

让我链接到一个类似的github上的示例以防上面不清楚.它更完整和详细.

Let me link to a similar sample on github in case the above is not clear. It is more complete and elaborate.

VBScript:我在看到你处理服务之前写了这个.我只是把它扔进去:要调用一个没有函数的脚本,你可以尝试这样的事情:

VBScript: I wrote this before I saw you dealt with services. I'll just throw it in: to call a script that doesn't have a function you can try something like this:

<!-- The VBScript file -->
<Binary Id='Sample.vbs' SourceFile='Sample.vbs' />

<!-- The Custom Action -->
<CustomAction Id='Sample.vbs' VBScriptCall='' BinaryKey='Sample.vbs' 
              Execute='immediate' Return='ignore'/>

<!-- And Insert Into Installation Sequence -->
<InstallExecuteSequence>
    <Custom Action='Sample.vbs' After='AppSearch'/>
</InstallExecuteSequence>

这应该适用于这样的脚本(Sample.vbs - 没有函数,只有一个隐式的主函数):

That should work for a script like this (Sample.vbs - no funtions, just an implicit main function):

MsgBox(Session.Property("ProductName"))

此处有关于 VBScript 自定义操作主题的答案:WIX 安装程序从 CustomAction 执行 vbscript.

There is an answer on the topic of VBScript custom actions here: WIX installer execute vbscript from CustomAction.

这篇关于Wix 的自定义动作调用 vb 脚本失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆