复制一个批处理文件的行为自定义操作 [英] Replicate Behavior of a Batch File in a Custom Action

查看:144
本文介绍了复制一个批处理文件的行为自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建工作中WiX的安装程序,我需要能够复制定制操作这个批处理文件的行为:

I'm creating a wix installer at work, and I need to be able to replicate the behavior of this batch file in a custom action:

start /d "C:\Program Files (x86)\Remindex" INSTSRV.EXE RemindexNP 
"C:\Program Files (x86)\Remindex\SRVANY.EXE"

我想创建一个使用一个正常的Windows应用程序,它SRVANY.EXE可以做服务。此批处理文件运行正常正常,但我似乎无法得到一个自定义操作,以做同样的事情。我曾尝试这样的:

I am trying to create a service using a normal windows application, which SRVANY.EXE can do. This batch file runs fine normally, but I can't seem to get a custom action to do the same thing. I have tried this:

<CustomAction Id="RunNP" FileKey="FILE_INSTALLFOLDER_INSTSRVEXE" 
              ExeCommand="RemindexNP [INSTALLFOLDER]SRVANY.EXE" Execute="commit" Return="ignore"/>

这个自定义操作不会导致我可以在日志文件中看到任何错误,但我不认为INSTSRV.EXE在接受我传递ExeCommand的参数。我知道INSTSRV.EXE和SRVANY.EXE存在,因为我跑InstallFinalize之前的自定义操作。

This custom action doesn't cause any errors that I can see in the log file, but I don't think instsrv.exe is accepting the parameters I'm passing in ExeCommand. I know that instsrv.exe and srvany.exe exist because I'm running the custom action before InstallFinalize.

任何人都知道什么是错我的自定义操作?

Anyone know what's wrong with my custom action?

我不会preFER,包括在我的安装文件夹中的实际批处理文件,因为它会没有理由在那里除了被上安装运行。我曾尝试包括一个在安装程序,但我不知道如何引用的安装目录。当我使用CD%%,它只是引用了系统文件夹中的某些原因。

I would prefer not to include an actual batch file in my install folder, as it would have no reason to be there besides being run on install. I have tried including one in the installer, but I don't know how to reference the install directory. When I use %cd%, it just references the system folder for some reason.

我试着用ServiceInstall和的ServiceControl元素,但安装卡上的启动服务。这里是我的组件:

I tried using ServiceInstall and ServiceControl elements, but the installer gets stuck on "starting services". Here is my component:

<Component Id="CMP_RemindexNP.exe" Guid="{3FB99890-752D-4652-9412-72230695A520}">
    <File Id="FILE_INSTALLFOLDER_RemindexNPEXE" Source="RemindexNP.exe" KeyPath="yes"/>
        <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\RemindexNP\Parameters">
          <RegistryValue Id="rg_remNP1" Action="write" Name="AppDirectory" Value="[INSTALLFOLDER]" Type="string"/>
          <RegistryValue Id="rg_remNP2" Action="write" Name="Application" Value="[INSTALLFOLDER]RemindexNP.exe" Type="string"/>
        </RegistryKey>
        <ServiceInstall DisplayName="RemindexNP" Id="srv_remNP" Name="RemindexNP" Start="auto" Type="shareProcess" ErrorControl="ignore"/>
        <ServiceControl Id="srvc_remNP" Name="RemindexNP" Remove="both" Start="install" Stop="uninstall" Wait="no"/>
      </Component>

和我的日志:

Action 17:15:08: StartServices. Starting services
Action start 17:15:08: StartServices.
StartServices: Service: Starting services
Action ended 17:15:08: StartServices. Return value 1.

任何建议将是极大的AP preciated。

Any suggestions would be greatly appreciated.

推荐答案

这是因为你不需要自定义操作一个很难回答的问题。该SRVANY.EXE作为服务宿主,因此可以编写成使用目录,组件,文件,ServiceInstall和(如果需要)的ServiceControl元素您的安装。

This is a trick question as you don't need a custom action. The srvany.exe acts as a service host and as such can be authored into your installer using the Directory, Component, File, ServiceInstall and (if desired) ServiceControl elements.

这篇关于复制一个批处理文件的行为自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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