0

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>

dgxhubbard
  • 703
  • 2
  • 7
  • 18

1 Answers1

1

You need to change the custom action to be Deferred and scheduled Before StartServices. Scheduling outside of the installation transaction after InstallFinalize is long after the service started.

I highly suggest reading and understanding:

http://www.installsite.org/pages/en/isnews/200108/index.htm

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • Thank you Christopher worked like a charm. I thought the install script that was built included the copy of files to the system or are they done as is from components? – dgxhubbard Jan 31 '20 at 23:31
  • There is no "install script" in MSI. I offer 1 hour complimentary mentoring sessions that can help you get started. Look up my website and send me an email if you are interested. – Christopher Painter Feb 01 '20 at 01:40