0

I want to launch a windows service immediately after installing it, so I created a launcher and added it as a custom action to the installer. However, it does not work. I can run the service manually, so I know other custom actions [register COM components and the service itself) worked properly. I tried to debug it by logging messages to file and to the event log. However, nothing is logged in either the file [No file is created] and same for the event log. I ran the launcher application separately to check for errors, and both the event log and file entries get created properly. So the conclusion seems to be that somehow windows installer is suppressing both file and event log output.

Please let me know how to resolve this issue. [Writing to file and event log from custom events in a windows installer project] Thanks, Sagar

PhilDW
  • 20,260
  • 1
  • 18
  • 28
Sagar Kapadia
  • 105
  • 1
  • 9
  • 1
    I think we need more info. How did you install the service? If with Installer class then you can override Install and add the startup. Also "it does not work" is not useful data, keeping in mind that a launch from an msiexec.exe process at install time is not the same as an interactive run, and you could still add debugging code to see where it's failing at install time. – PhilDW Jan 14 '18 at 17:58
  • I installed the service using the Visual Studio Installer 2015 addin . It provides custom actions where you can launch separate exes. I launch 3 exes sequentiallythe first one registers the COM components , the second one registers the service itself [actually, the service self registers], and the third is the launcher. I added output to a text file as well as to the event log in the launcher [3rd custom action]. But there is not file created and no entry in the event log. Both work [a file is created and events are created in the event log] if I run the launcher outside the installer – Sagar Kapadia Jan 15 '18 at 01:31
  • Your launcher is code you wrote that doesn't work when run as a custom action, so you're basically asking why the code doesn't work as a custom action. I believe you could figure that out by putting debug code in there to see if it starts at all and how far it gets and so on. Or you could post the code to see if anyone can see why it may not work as a custom action. – PhilDW Jan 15 '18 at 18:19
  • I tried putting debug code in it , but there was no output. I also tried starting a windows forms application, and it did not show up. So either the third command is not running at all, or all out put is getting suppressed – Sagar Kapadia Jan 17 '18 at 13:36
  • Post the code. It is still the case that you have failing code that you cannot debug and you're asking SO to fix it without actually showing any of it. – PhilDW Jan 17 '18 at 18:25
  • 1
    Using the [ServiceControl table](https://msdn.microsoft.com/en-us/library/windows/desktop/aa371634%28v=vs.85%29.aspx) you should be able to start your service via a built-in MSI feature? The [ServiceInstall table](https://msdn.microsoft.com/en-us/library/windows/desktop/aa371637(v=vs.85).aspx) takes care of the service install - without any custom actions. You should also [be very careful with custom actions in an MSI](https://stackoverflow.com/a/46179779/129130). Maybe also check [common design errors in MSI files](https://stackoverflow.com/a/45840087/129130). Your launcher likely never runs. – Stein Åsmul Jan 17 '18 at 19:25
  • Thanks a lot, stein. I used orca to edit the service control table and add an entry to it. I had to change the sequence of StartServices to 6575 , (6600 is the sequence for Finalize Install), to make sure it ran at the right time.I struggled for two and a half days before asking SO. Now the service is started after installation. It finally works, thanks to you. – Sagar Kapadia Jan 19 '18 at 02:48
  • PhilDW, I still want to figure out why the launcher did not work, because I also want to run a Windows forms app after the installation, and that doesn't work too. I will post the code of the console application (launcher) later today. I can't figure out where code for installer is. Thanks – Sagar Kapadia Jan 19 '18 at 02:53

0 Answers0