Search code examples
servicewixcustom-action

WiX custom action using CAQuietExec fails with invalid command line error


I have a custom action that requires elevated privileges. The purpose of this custom action is to run sc.exe and remove the service triggers for a service that ships with Windows (w32time).

Here are the snippets of significance:

<Property
     Id="removeW32TimeTrigger"
     Value="&quot;[SystemFolder]sc.exe&quot; triggerinfo w32time delete"
/>

<CustomAction
     Id="removeW32TimeTrigger"
     BinaryKey="WixCA"
     DllEntry="CAQuietExec"
     Execute="deferred"
     Return="ignore"
     Impersonate="no"
/>

<InstallExecuteSequence>
     <Custom Action="removeW32TimeTrigger" After="InstallInitialize" />
</InstallExecuteSequence>

I followed the example for deferred execution here: http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html

The error from the log appears to be having trouble with my syntax for where to find sc.exe.

Action 11:36:48: removeW32TimeTrigger. 
CAQuietExec:  Command string must begin with quoted application name.
CAQuietExec:  Error 0x80070057: invalid command line property value
CAQuietExec:  Error 0x80070057: failed to get Command Line

I'm clearly doing something wrong. Any help would be appreciated.


Solution

  • Since you are running the CA in deferred you need to send CustomActionData with a type 51 custom action instead of using Property.

    Try this and see if it works:

    <CustomAction Id='removeW32TimeTrigger_set'
                  Property='removeW32TimeTrigger'
                  Value='"[SystemFolder]sc.exe" triggerinfo w32time delete'
                  Execute='immediate'/>
    
    <CustomAction
         Id="removeW32TimeTrigger"
         BinaryKey="WixCA"
         DllEntry="CAQuietExec"
         Execute="deferred"
         Return="ignore"
         Impersonate="no"
    />
    
    <InstallExecuteSequence>
         <Custom Action="removeW32TimeTrigger_set" After="CostFinalize" />
         <Custom Action="removeW32TimeTrigger" After="InstallInitialize" />
    </InstallExecuteSequence>