9
votes

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.

1
Okay... So while moving this from an immediate to a deferred CA I neglected to remember that [SystemFolder] won't expand. I also screwed up and posted a stale error log for the issue. The error log that would match the snippets above fails as follows: CAQuietExec: Error 0x80070002: Command failed to executeskiloup

1 Answers

11
votes

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>