We have a wix installer, on a new install it is required to create our database and start our service after the database is created. Because services are started long before InstallFinalize, the service fails to start because the database has not been created. I tried using InstallFiles to run the database create but the database create application never started.
Next I moved to sc.exe start "My Server" as referenced here and by deferred action and that did not work.
I removed the custom action to start the service and tried ScheduleReboot which did not prompt the user to reboot and forced me to reboot the machine to be able to uninstall.
How do I either schedule the service to start after the database has been created or force a reboot that prompts the user they must reboot for changes to take effect?
<InstallExecuteSequence>
<ScheduleReboot After='InstallFinalize'>NOT Installed AND NOT
WIX_UPGRADE_DETECTED</ScheduleReboot>
</InstallExecuteSequence>
Service Controller
<Component Id="ServiceComponent" Directory="BIN_FOLDER" MultiInstance="yes"
Guid="{04EAB7AF-2DC5-4807-85D7-BA9CDE65FD82}" >
<File Id="ServerExe" KeyPath="yes" Vital="yes" Source="$(var.BinFilesSourcePath)\MyServer.exe" />
<ServiceInstall
Id="ServiceInstaller"
Name="My Server"
DisplayName="My Server"
Type="ownProcess"
Start="auto"
ErrorControl="normal"
Description="My Server"
Account="NT AUTHORITY\LocalService"
Vital="yes"
Interactive="no" />
<ServiceControl
Id="StartService"
Name="My Server"
Remove="uninstall"
Start="install"
Stop="both"
Wait="yes" />
</Component>
Create Database
<CustomAction
Id="RunDataUtility"
Directory="BIN_FOLDER" ExeCommand="[BIN_FOLDER]\DataUtility.exe"
Execute="immediate" Impersonate="yes" Return="ignore" />
<InstallExecuteSequence>
<Custom Action="RunDataUtility"
After="InstallFinalize" ><![CDATA[ NOT(Installed) ]]></Custom>
</InstallExecuteSequence>