简体   繁体   English

向WiX安装程序添加自定义操作

[英]Adding Custom Action to WiX Installer



Im trying to run a custom command in the cmd using WiX Installer. 我试图使用WiX Installer在cmd中运行自定义命令。
I make use of a include file in the Product.wxs wich is correctly consumed throughout the installation. 我利用Product.wxs中的include文件,在整个安装过程中正确使用了该文件。

I have 3 Custom actions and 2 of them are working fine . 我有3个自定义操作,其中2个工作正常 The one that seems not be working is: 似乎不起作用的一个是:

<CustomAction Id='AddDefaultDomain'
        Directory='TARGETDIR'
        Impersonate="no"
        Execute="immediate"
        ExeCommand="C:\windows\system32\inetsrv\appcmd.exe set config /section:basicAuthentication /defaultLogonDomain:[%USERDOMAIN]  /commit:apphost"
        Return="asyncNoWait" />

The installer runs correctly and when I call AppCmd through a cmd windows and Copy->Paste the 'ExeCommand' in the cmd and execute it, it just works fine. 安装程序可以正确运行,当我通过cmd窗口调用AppCmd并在cmd中复制->粘贴“ ExeCommand”并执行它时,它就可以正常工作。

Probably this is something simple but for now I do not understand why it is not working. 可能这很简单,但是现在我不明白为什么它不起作用。
All help is appreciated. 感谢所有帮助。

Full Include File 完全包含文件

<?xml version="1.0" encoding="utf-8"?>
<Include>
  <!-- Create Scheduled Task -->
  <InstallExecuteSequence>
    <Custom Action="CreateScheduledTaskGoogleService" After="InstallFiles">NOT Installed</Custom>
    <Custom Action="CreateScheduledTaskGoogleServiceId" After="CostFinalize">NOT Installed</Custom>
    <!-- Add Defualt DOmain -->
    <Custom Action="AddDefaultDomain" After="CostFinalize">NOT Installed</Custom>

  </InstallExecuteSequence>
  <CustomAction Id="CreateScheduledTaskGoogleService" Return="check" Impersonate="no" Execute="deferred" BinaryKey="WixCA" DllEntry="CAQuietExec" />
  <CustomAction Id="CreateScheduledTaskGoogleServiceId" Property="CreateScheduledTaskGoogleService" Execute="immediate" Value="&quot;[SystemFolder]SCHTASKS.EXE&quot; /CREATE /TN &quot;ActaNet Control - Google Sync&quot; /XML &quot;[INSTALLFOLDERPROGRAMFILESGOOGLE]ScheduledTask.xml&quot;" />

  <!-- DOES NOT SEEM TO BE WORKING! -->
  <CustomAction Id='AddDefaultDomain'
        Directory='TARGETDIR'
        Impersonate="no"
        Execute="immediate"
        ExeCommand="C:\windows\system32\inetsrv\appcmd.exe set config /section:basicAuthentication /defaultLogonDomain:[%USERDOMAIN]  /commit:apphost"
        Return="asyncNoWait" />

  <!-- Delete Scheduled Task -->
  <InstallExecuteSequence>
    <Custom Action="TaskDeleteGoogleService" Before="CreateScheduledTaskGoogleService">REMOVE="ALL"</Custom>
  </InstallExecuteSequence>
  <CustomAction Id="TaskDeleteGoogleService" Return="ignore" Execute="deferred" Directory="TARGETDIR" Impersonate="no" ExeCommand="SCHTASKS.EXE /DELETE /TN &quot;ActaNet Control - Google Sync&quot; /F" />
</Include>

The very first thing i would do is to confirm that the command is actually being executed. 我要做的第一件事就是确认命令实际上正在执行。 Make use of a tool such as Process Monitor to confirm this. 使用诸如过程监视器之类的工具进行确认。

Once this is done, i would see if the command is modifying something on the target system which would require elevated privileges to do so. 完成此操作后,我将查看该命令是否正在目标系统上进行某些修改,而这将需要提升的特权才能这样做。 If so,i would change the value of the Execute attribute to "deferred" and see if it works. 如果是这样,我会将Execute属性的值更改为“ deferred”,然后查看它是否有效。 It seems like you are trying to change something on the target system using an immediate mode custom action. 似乎您正在尝试使用即时模式自定义操作来更改目标系统上的某些内容。 Marking the action as deferred would also require you to place the action between "InstallInitialize" and "InstallFinalize". 将操作标记为“延迟”还需要将操作放置在“ InstallInitialize”和“ InstallFinalize”之间。

In your present case, you are trying to launch the exe in immediate mode. 在您当前的情况下,您正在尝试以即时模式启动exe。 Immediate mode impersonates the logged on user, hence in UAC environments, any custom action which modifies the target system can fail. 即时模式模拟了登录用户,因此,在UAC环境中,修改目标系统的任何自定义操作都可能失败。

Hope this helps. 希望这可以帮助。

First, change "Execute" of your custom action to Deffered, because you have no system permissions in Immediate type. 首先,将自定义操作的“执行”更改为“延迟”,因为您在“立即”类型中没有系统权限。

Second, use loggging to see what happens during your installation. 其次,使用loggging查看安装过程中发生的情况。 Using below concole command will creates log file for installation process in same folder in wich YourInstaller.msi is located: 使用以下conconle命令将在安装YourInstaller.msi的同一文件夹中创建安装过程的日志文件:

msiexec -i YourInstaller.msi -l*v log.txt

You can find in result log.txt file by custom action name to see what happens, when installer tried to execute it. 您可以通过自定义操作名称在结果log.txt文件中找到安装程序尝试执行该文件时发生的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM