Search code examples
wixwindows-installercustom-action

Wix Executing command using custom action not working


I have the following custom actions which normally remove the exe from windows service and add it back,

<CustomAction Id="ExecRemoveService" Directory="INSTALLDIR" Execute="immediate" ExeCommand="MyExe.exe -remove" Return="ignore" />
    <CustomAction Id="ExecInstallService" Directory="INSTALLDIR" Execute="immediate" ExeCommand="MyExe.exe -install" Return="ignore" />
    <InstallExecuteSequence>
      <Custom Action="ExecRemoveService" After="InstallFinalize" />
      <Custom Action="ExecInstallService" After="InstallFinalize" />
    </InstallExecuteSequence>

When run the MSI nothing happening, it successfully finish but nothing inside windows service I am seeing.


Solution

  • This one worked for me,

        <CustomAction 
    Id="ExecInstallService" 
    Directory="INSTALLDIR" 
    Execute="deferred" 
    ExeCommand='cmd.exe /k "MyService.exe -remove &amp; MyService.exe -install &amp; exit"' Return="check" Impersonate="no" />