Wix的自定义操作无法调用vb脚本

问题描述 投票:1回答:2

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

我使用以下代码,该代码无法正常工作。我搜索了很多,但没有找到解决方案。

<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"/>
wix windows-installer
2个回答
1
投票

WiX IIS Elements:如果这是所有IIS,我会尽可能避免脚本和自定义操作,并使用WiX的内置IIS元素。这是a Web-installer sample from Rainer Stropek available on github.com

寻找<iis:WebVirtualDir ... />等人。 Find the WiX Documentation here。我相信你应该能够在没有太多自定义动作的情况下完成你所需要的。

DISM.exe:Stropek自己在set up IIS using DISM.exe的另一个示例源中使用自定义操作。不确定我会这样做(虽然没有其他建议),但它是自定义操作和IIS的示例。


极品飞车:关于您的安装性能问题。也许您需要禁止创建还原点并限制文件成本计算? Windows Installer引擎允许这样做 - 请参阅下面的链接。我怀疑它会非常有效。我认为安装程序中肯定存在其他问题。一些超时问题?它可能与其他自定义操作,慢速网络或其他一些问题有关。你能详细说明你的部署方案吗?

无论如何,here is some documentation on speeding up MSI installations in general。基本上MSIFASTINSTALL财产是我唯一推荐的。 DISABLEROLLBACK可能会导致真正的问题。


记录:我通常建议设置开发人员enable default verbose MSI logging - 如“Globally for all setups on a machine”部分所述,在需要时始终准备好日志文件。它是为TEMP folder中的每个MSI操作创建一个随机名称,然后通过modify进行排序以获取最新的一个。日志文件可能会提供有关安装速度缓慢的原因的线索 - 只需确定实际发生的情况。抱歉,如果这只是显而易见的琐事,你已经建立了这个。

手动创建日志文件:

msiexec.exe /i C:\Path\Your.msi /L*v C:\Your.log

解释MSI日志:解释日志文件有时可能具有挑战性。 Here is an answer with some links to help with this


1
投票

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

<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>

Look! No custom actions! :-) - Just MSI auto-magic。无需为此使用任何自定义操作。如果您的服务可执行文件按预期运行,则MSI功能齐全且可靠。

如果上述情况不明确,Let me link to a similar sample on github。它更完整,更精细。


VBScript:在我看到你处理服务之前,我写过这个。我只是把它扔进去:调用一个没有函数的脚本你可以试试这样的东西:

<!-- 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 - 没有功能,只是一个隐含的主要功能):

MsgBox(Session.Property("ProductName"))

这里有关于VBScript自定义操作主题的答案:WIX installer execute vbscript from CustomAction


© www.soinside.com 2019 - 2024. All rights reserved.