wholt@nabancard.com
Posts: 9
Joined: Mon Feb 01, 2021 11:15 pm

Service Start/Stop Precheck

Mon Feb 01, 2021 11:31 pm

Can you just add a checkbox prechecks to the Custom Action Service Start/Stop to check to see if the service is installed and running (or stopped respectively)

The use case is right now I have several services that are installed, On Install I do a start service at end, but if the service didn't exist then I don't want attempt to start. More importantly is on uninstall, the service may already be stopped, in which case a service stop fails. To properly handle you need to do a detect service. Given that proper error handling dictates you always check (really necessary if the fail installation ... is checked)

I understand I can (and currently do) check the above either via the detect service or custom method in a installer dll, it would just be simpler and eliminate extra steps if it were included.

Catalin
Posts: 6540
Joined: Wed Jun 13, 2018 7:49 am

Re: Service Start/Stop Precheck

Thu Feb 04, 2021 4:38 pm

Hello and welcome to our forums,

As you have already mentioned, the check can be done via the "Detect Service" predefined custom action.
it would just be simpler and eliminate extra steps if it were included.
I am not quite sure I fully understand what you mean here.

Would you like the check to be automatically implemented in the "Start Service"/"Stop Service" custom actions?

If this is the case, I'm afraid it is not quite achievable, as starting and stopping services rely on the "StartServices Action", which is a standard action (proprietary to Windows Installer) and it can not be modified.

Also, it is recommended to keep a custom action as simple as possible. Most of our predefined custom actions do only one step (e.g. "Launch File", "Stop Service", etc.).

Thank you for your understanding!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

wholt@nabancard.com
Posts: 9
Joined: Mon Feb 01, 2021 11:15 pm

Re: Service Start/Stop Precheck

Thu Feb 04, 2021 7:27 pm

I understand, but then, particularly, the Stop more so than the Start becomes a worthless custom action since I should always be coupled with checking to see if the service was started, or even exists. One is better off using either a windows installer custom dll call/method, or a powershell script.

I was using just the Solo custom actions that has now caused hundreds of uninstalls to orphan my product. The cause ended up that the service stop was often times ran against a service that no longer existed, or already stopped, causing the uninstall to halt with error, only to leave the a product that I have to use a third party product to force uninstall. Replicate this to a couple hundred installs of these previous builds, and I am left with spending lots of hours fixing on remote systems.

Given you cannot change, then there should be sufficient warning on the custom action to indicate, stopping a service that is already stopped will produce and error, as well as stopping a service which does not exist will result in an error.

In the end I guess I just wanted the 2 actions integrated together, to prevent the need to add both, forget the detect, and basically type in the same info, only to add the results from the prior to a conditional

Thanks for answering though.

Catalin
Posts: 6540
Joined: Wed Jun 13, 2018 7:49 am

Re: Service Start/Stop Precheck

Fri Feb 05, 2021 3:30 pm

Hello,
The cause ended up that the service stop was often times ran against a service that no longer existed, or already stopped, causing the uninstall to halt with error, only to leave the a product that I have to use a third party product to force uninstall
I am really sorry you have encountered such a behavior.

If possible, could you please give me some more details about your package failing due to the "Stop Service" custom action when the service is already stopped?

I have just done some tests (because I kind of doubted this behavior) and the setup did not fail when the service was stopped. Here are the steps I took:

- create the service using sc.exe

- start the service

- stop the service

- create a new project where I have added the "Stop Service" custom action to run on install

- installed the setup - it installed without any errors, even though the service was stopped and I attempted to stop it through the custom action

Maybe the error was thrown by something else - for instance, the lack of administrative privileges when trying to stop the service.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”