Search code examples
cmdwixcustom-action

WiX v4 - execommand not working - works fine on command line


I have a custom action which runs a packaged exe :

<CustomAction Id="RunIt" 
          Directory="INSTALLFOLDER" 
          ExeCommand="[INSTALLFOLDER]MyEXE.exe /silent >C:\output.log" 
          Execute="deferred" 
          Impersonate="no" 
          Return="asyncWait" />

the exe works fine - the /silent command works fine - however the >C:\output.log doesn't seem to do anything.

When i include the >output command, it does extend the install duration, which i would expect - as it needs the time to write the log, but it still doesnt output anything.

I previously had a .cmd which contained the full execommand(and this was included in the custom action instead) - this worked fine - but i would like to try and reduce unnecessary files if i can, and i dont see why this wouldnt work.


Solution

  • The >C:\output.log syntax is interpreted by cmd.exe. When you use an exe CustomAction, the Windows Installer straight up calls ::CreateProcess(). ::CreateProcess() does none of the syntax processing that cmd.exe does, so you're probably getting the values >C:\output.log as one of the parameters input to your program.

    You either need to launch cmd.exe to then launch your .exe, or your .exe needs to provide an option to log to a file.