Bug 51496 - NSIS - Warn that duplicate service name will result in install failure
Summary: NSIS - Warn that duplicate service name will result in install failure
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Packaging (show other bugs)
Version: trunk
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-11 12:05 UTC by Konstantin Kolinko
Modified: 2017-11-22 21:30 UTC (History)
1 user (show)



Attachments
Check wheather a service of the same name is allready installed. (1.38 KB, patch)
2012-08-19 18:16 UTC, Ralph Plawetzki
Details | Diff
Check wheather a service of the same name is allready installed. (949 bytes, patch)
2012-08-28 08:51 UTC, Ralph Plawetzki
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2011-07-11 12:05:57 UTC
It was noticed on the users list, that it is not possible to install two copies of Tomcat with the same service name.

http://markmail.org/message/rcmayrkydamywbpw

It would be preferable to check for a duplicate name before starting the installation, but I do not know of a way to check existing service names in installer.

Is there an API method, or maybe we can look up in the Registry?


It looks that when this error occurs it is too late to go back to the configuration pages, or to specify a different name. At least we can tweak text of the message that appears. The current text is:

"Failed to install Tomcat7 service.
Check your settings and permissions.
Ignore and continue anyway (not recommended)?" abort|retry|ignore
Comment 2 Ralph Plawetzki 2012-08-19 18:16:01 UTC
Created attachment 29251 [details]
Check wheather a service of the same name is allready installed.

Dear All,

I'd like to propose the attached patch in svn diff format against trunk.
After checking how tomcat.nsi got improved with r1139117 and further commits the attached patch addresses the check wheather a service of the same name is allready installed.

The patch also applies to tc7.0.x/trunk and tc7.0.x/tags/TOMCAT_7_0_29.

Regards,
Ralph
Comment 3 Konstantin Kolinko 2012-08-27 15:12:37 UTC
-1 for the patch (attachment 29251 [details])

It does not check that a service is installed.

What it checks is whether the "Tomcat Monitor" application is configured to auto-launch on Windows startup or not. That is quite a differing thing.
Comment 4 Ralph Plawetzki 2012-08-28 08:51:01 UTC
Created attachment 29289 [details]
Check wheather a service of the same name is allready installed.
Comment 5 Ralph Plawetzki 2012-08-28 08:51:33 UTC
Dear Konstantin,

thank you very much for the fast review.

I'd like to explain why I checked for the Tomcat Monitor application whether it is configured to autolaunch: in tomcat.nsi $TomcatServiceName is also part of the registry entry stored for the Tomcat Monitor application and it seemed better to check that than to use an external NSIS library to read the installed services as suggested in comment 1.

But you are absolutely right, it's better to check if a service of the same name is already installed. I looked a little further into MSDN documentation and found that services are also listed in the registry under HKLM SYSTEM\CurrentControlSet\Services\ so I changed  the registry check in the patch.

Please find the new patch attached.
You can check that it works by installing the tomcat service and running the installer a second time. If a service of the same name exists, it prompts the user with a pop-up and remains on the configuration page.

The patch is in svn diff format against trunk.

Regards,
Ralph
Comment 6 Konstantin Kolinko 2012-08-28 19:14:19 UTC
Do you have a link to MSDN page describing this?
Comment 7 Ralph Plawetzki 2012-08-29 09:04:47 UTC
http://msdn.microsoft.com/en-us/library/ms682544(v=vs.85)
The SCM maintains a database of installed services in the registry. The database is used by the SCM and programs that add, modify, or configure services. The following is the registry key for this database: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.

This key contains a subkey for each installed service and driver service.
Comment 8 Mark Thomas 2017-11-22 21:30:01 UTC
Thanks for the patch. I fixed a typo - otherwise it was applied as provided.

Fixed in:
- trunk for 9.0.2 onwards
- 8.5.x for 8.5.24 onwards
- 8.0.x for 8.0.48 onwards
- 7.0.x for 7.0.83 onwards