skingswell
Posts: 29
Joined: Tue Nov 29, 2016 2:24 pm

Service Not deleted on Uninstall HELP!

This seems to be a common issue with various solutions available on this forum. I have read them all but still struggling to find the best/correct way to approach this.
I have an AI project which has multiple instances enabled. Each instance installs a windows service with a service name that is named based on a property value to make it relative to the instance installed.
When I remove an instance or even the default instance, the service doesn't delete on uninstall. If I stop the service prior to uninstall, the application uninstalls correctly.

So I need to figure out how to stop a service which is named based on a property value. I have the Service Operation set to STOP and DELETE on uninstall but clearly this is not working.

Any help appreciated as I have been looking at this for a while and cannot progress.... :-0
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Service Not deleted on Uninstall HELP!

Hello Sarah,
So I need to figure out how to stop a service which is named based on a property value. I have the Service Operation set to STOP and DELETE on uninstall but clearly this is not working.
This issue is caused by limitation of our multiple instances support.

A possible workaround could be launching a bat file instead of using our predefined support for stopping/uninstalling the services.

Please follow the steps:

1. Create a bat file with the following content:

Code: Select all

sc stop %1
sc delete %1
pause
The pause command is for debugging purposes.

2. Add this bat file as a temporary file to your project : Temporary Files Operations in the Files and Folders Page

2. Avoid using the predefined support for service stop and delete. To achieve this, go to "Services" page, "Control Operations" and select your service. In "Actions" field, only enable "Start"

3. You need to Launch this bat file through a custom action. Please take a look here: How to launch a CMD or BAT file
This custom action should be configured as shown in the attached screenshot and should only run on Uninstall.

After finishing debugging, you should also enable "Hide program's windows" option and delete the "pause" command from the bat file.

For a better understanding of this workaround, please take a look on the attached sample I've made for your scenario.

Best regards,
Sorin
Attachments
screenshot.png
screenshot.png (16.33 KiB) Viewed 6305 times
Sample delete service.zip
(7.09 KiB) Downloaded 290 times
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
skingswell
Posts: 29
Joined: Tue Nov 29, 2016 2:24 pm

Re: Service Not deleted on Uninstall HELP!

Sorin, thanks for this. I have got to the point now where at least the batch file executes on uninstall.
The problem is I am not using [ProductVersion] as part of the service name. Its based on a parameter on a dialog page and when the batch executes the Property value is blank.
I used a property value so every instance of the install referenced the correct company I was installed the product for. This works okay but seems to be causing me issues removing the service.
Is there a way around this?
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Service Not deleted on Uninstall HELP!

Hello,
The problem is I am not using [ProductVersion] as part of the service name. Its based on a parameter on a dialog page and when the batch executes the Property value is blank.
The propery value is blank because in order for a property to be available during maintenance (uninstall) it should be set as a "Peristent Propery" : http://www.advancedinstaller.com/user-g ... perty.html

Unfortunatelly, this wouldn't help in your case because of the multiple instances scenario. Basically, the property will persist having the value provided at the last installed instance.

I highly recommend using ProductName property reference in your service name. You this is not suitablefor you, you could store the property you want to use in the service name and retreive it from the registry at uninstall.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
skingswell
Posts: 29
Joined: Tue Nov 29, 2016 2:24 pm

Re: Service Not deleted on Uninstall HELP!

Sorin, thanks for your reply. I haven't had a chance to get back to this problem.
I will attempt to try the registry option to get the property value. I am not entirely sure where to start with this and any pointers you have will be most useful. :-)
I understand how to set a registry value on install but not sure how to read on uninstall?
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Service Not deleted on Uninstall HELP!

Hello,

You could retrieve a value from the registry using the Search feature.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
skingswell
Posts: 29
Joined: Tue Nov 29, 2016 2:24 pm

Re: Service Not deleted on Uninstall HELP!

Sorin, thanks for your help this worked. I now have services for multiple instances being deleted on uninstall :-)
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Service Not deleted on Uninstall HELP!

Hello,

Your are welcome!
Please let me know if you have any other questions.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”