Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hi,

I'm having some issues when I install a service and either start it or not start it based on user selection through a property value. On Uninstall, it will not remove the service, even though the log shows that it did. This was working before, but now it doesn't seem to work with the latest version.

Steps to recreate:

* Create folder and add exe for the service under its own folder; one for ServiceStarted & ServiceStopped.
* Enable "Install folder content into parent folder" for both of the folders
* On the Component, condition it with the public property. In my case I used START_SERVICE="checked" & START_SERVICE <> "checked"
* On a Dialog place checkbox with START_SERVICE property
* Create the service & control operations for both services. The ServiceStarted will have "Start" checked and ServiceStopped will have "Start" unchecked for Actions under Control Operations
* Install the service and then uninstall it. The application is removed, but the service is left.

When I remove one of the services and only have it install one, it removes the service correctly on uninstall. Also, the "Set Log on as a service policy for selected username" doesn't function when there are two services.

I emailed two project files and their msi's. One is with both services and the other is with only one service.
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hello Collins,

Unfortunately, I could not test the sent setup, because I can not run the service on my system (I got the "Failed to run system service" error when I was trying to deploy the setup). Since I have run the setup as administrator, my guess is that some dependencies are missing from my machine.

Does your service has any dependencies beside the .NET Framework 4.7.1? If yes, could you please let me know which are the dependencies so I can install them on my test machine?

Beside that, I have a question:

- from what I have seen in your project, you have the executable file of your service added twice in your project. I am not quite sure I understood why you have done that. Could you please explain me that so I can better understand what you are trying to achieve?

Also, I have noticed that the condition you are using on your service component is incorrect. A checkbox can have the following states (values):

- "CheckBox" - if the checkbox is checked

- "" - otherwise

Your condition looks like this:

START_SERVICE = "checked"

or

START_SERVICE <> "checked"

This means that even if you check / uncheck the checkbox, the second condition will always be true. I am not quite sure if and how this affects your setup, but I wanted you to know about it.

Looking forward to hearing from you.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hi Catalin,

Other than the framework requirement, there are supported OS launch conditions set for only Windows 8 and up.

The exe was added twice since creating a service & control operation is tied to its component and since I have two senarios; one to start the service and one to not start the service on install, two executable's were used for two components so they can be conditioned based on the users choice. This was recommended to me as a solution by AI.

As for the START_SERVICE conditions, that was my thought as well, but when testing it, it didn't seem to be the case with the checkbox state and I found this to work even if the user unchecks it and checks it again.
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hello Collins,

First of all, please accept my apologies for the delayed reply, but we were quite busy lately.

I have started investigating this once again earlier today.

Finally, I was able to have the setup installed and the service started. I was not able to start the service because I was trying to install it from a local user account instead of a domain account.

However, after testing the scenario presented by you, I was not able to replicate the described behavior. The service entry was correctly removed from the "services.msc" view.

Most probably, this happens due to some shared resources between the two services (since you have said that by having only one service installed - e.g. the second setup that you have sent me, it works as expected).

In order for me to further investigate this, could you please also send me the log file of the uninstallation process?

Looking forward to hearing from you.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hi Catalin,

I attached both the service install & uninstall log. I'm not sure what the shared resource is as everything related to them is in their own individual component.
Attachments
ServiceNotRemoved.png
ServiceNotRemoved.png (1.96 KiB) Viewed 25407 times
WFProcessorUninstall.txt
(607.61 KiB) Downloaded 696 times
WFProcessorInstall.txt
(823.36 KiB) Downloaded 711 times
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hello Collins,

Thank you for the sent log files.

I have further investigated them and I think that I was able to find the culprit here.

If you watch closely at the log file, you will be able to see the following line:

MSI (s) (0C:38) [10:15:12:598]: Disallowing uninstallation of component: {A44152E3-FFDB-445F-B043-AFA1E52D313E} since another client exists

After searching in the .AIP file for that GUID, I could find out that this component is the following: "Config_Native"

and it contains the following XML file: "ImageRight.Workflow.Processor.WindowsService.exe.config"

This is the intended behavior. The resources will be uninstalled when all the products containing these components are uninstalled.

For more information about this, please have a look over our "Why files are left behind after package uninstall" article.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Catalin,

I'm not sure what that component has to do with the service being left on uninstall as they don't share the same component. The "ImageRight.Workflow.Processor.WindowsService.exe.config" component has the "Permanent" attribute set on it so I expect the message "Disallowing uninstallation of component" to show in the log, while the service exe is not marked as permanent.

The stopping and removal of the service occur before removal of the files so I don't see a file dependency to be the issue.

I have this same type of configuration in other AIP's without this issue.
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hello Collins,

I have started investigating this once again today.

Unfortunately, the result was the same as of last time. The service is correctly uninstalled on my machine.

I've also had another look over the sent uninstallation log file. From it, it indeed seems that the service is getting uninstalled. However, the reason behind this is nowhere to be found in the log.

From all of this, it still seems to me that somehow the component of your EXE is somehow shared between multiple products. If that would be the case, then the behavior is normal. If Windows Installer was to uninstall the service, then the other product using the same components would become corrupt.

Could you please try to test this on a clean machine (e.g. a freshly installed Windows VM) and let me know if the problem still persists?

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hi Catalin,

Yes, I already tried installing on a clean Windows 10 & new 2016 server using a domain account and get the same results where it leaves the service behind.

I provided two project and msi files. Are you using the msi that contains the two conditioned component services?
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hello Collins,
Are you using the msi that contains the two conditioned component services?
Yes, I am using the MSI that contains both service components.

I have tested this once more on a Windows Server 2012 R2 that is part of a domain controller, from and admin account and the results were the same, the service got correctly stopped & removed.

I am wondering if I am missing something during the install & uninstall process. Could you please give me a more detailed step by step about the installation and uninstallation process (do you simply double click the installer and then remove it from control panel?)?

Also, during the uninstall, please check the Event Viewer and see if there is anything related to the component of your service logged.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Catalin,

Here are the steps to recreate:
https://www.screencast.com/t/I5P7KTNh91

Also, this time I decided to try and uninstall the product from the msi dialog and the service was removed:
https://www.screencast.com/t/qdZfa3tZh

So I don't understand why it won't work from add\remove programs or command line, but it works from the msi.
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hello Collins,

Thanks for the provided steps.

Unfortunately, I was still not able to reproduce this issue.

When you are reproducing this issue, could you please open the Event Viewer and check under the following tree:

Windows Logs --> Application --> search for the events which have the "MsiInstaller" source.

These logs may give us some additional information about the uninstall process.

Additionally, could you please try and test this on a clean machine? By clean machine, I mean a virtual machine with a fresh OS install, without any additional applications installed. From what I could see in the sent videos, those tests were not performed on a clean machine (I could see a lot of applications installed in the Control Panel).

Please let me know the results of the process (install and uninstall on a clean machine).

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Hi Catalin,

Sorry for the delay. Here is the same test on a clean server, one of the first servers I had used previously. It made no difference.

https://www.screencast.com/t/DkzpcyBXHge
Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Start Or Stop Service On Install Based On Property Doesn't Uninstall Service

Here are the Event Viewer logs for Application and System. Just remove ".Log" for the extention.
Attachments
System.evtx.log
(68 KiB) Downloaded 680 times
Application.evtx.log
(68 KiB) Downloaded 654 times

Return to “Common Problems”