Vanshu Narang
Vanshu Narang

Reputation: 1

Custom scheduler for windows service restart using WiX ExeCommand

Where exactly can I add a custom action for scheduling tasks for my Windows service to run every night at 3 am for restart using Wix. Below is my code in ComponentsGenerated.wxs:

<Component Id="cmp40F206ED3A78EAA487631B7F03487BCB" Guid="{4866E196-A083-4DEB-825B-D99A9865A031}">
<File Id="fil27B6984A3653D3D09558A0F0B7E0F6AF" KeyPath="yes" Source="$(var.BasePath)\Multisoil.exe" /><ServiceInstall Id="ServiceInstaller" Type="ownProcess" Name="BundleMultiSoil" DisplayName="MultiSoil" Description="Monitors soil readers" Start="auto" Account="LocalSystem" ErrorControl="normal" Arguments=" /start MultisoilService"/>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="MultiSoil" Wait="yes"/></Component>
<!--then I have several other components, please note that this components generated file was auto-generated, but I still added the service install part here for the exe.-->
</Directory></DirectoryRef>
<CustomAction Id="CreateScheduledTask" Directory="TARGETDIR" ExeCommand="[SystemFolder]schtasks.exe /Create /SC DAILY /TN RestartService /TR "net stop BundleMultiSoil && net start BundleMultiSoil" /ST 03:00 /RU SYSTEM" Execute="immediate" Impersonate="no" \>
<Custom Action="CreateScheduledTask" NOT REMOVE After="InstallInitialize"></Custom>

Product: Multisoil App (64bit) -- Error 1722.

There is a problem with the:

is Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action CreateScheduledTask, location: C:, command: C:\WINDOWS\SysWOW64\schtasks.exe /Create /SC DAILY /TN RestartService /TR "net stop BundleMultiSoil && net start BundleMultiSoil" /ST 03:00 /RU SYSTEM

The service was installed fine before. just not able to custom action it. Don't understand what I am doing wrong.

Upvotes: 0

Views: 47

Answers (1)

Rob Mensching
Rob Mensching

Reputation: 36006

ExeCommand is not a batch file. It's a single executable and it's command line. The && is being passed to the schedtask action and probably not valid command line parameters. Using cmd.exe that would be interpreted as a new command... but that's because cmd is interpreting the whole string.

Upvotes: 0

Related Questions