Hi all,

One Windows my installer is periodically throwing an error when creating a Windows service, as part of the post installation steps I'm running the following:

<!-- Adding Windows Service -->

                <!-- Start it -->

My problem is that it's very random in failing to create the service, I've tried a number of times running it in debug mode but can't reproduce the problem. So is it possible for me to add some form of debug logging to my installer? Failing that is there a known set of conditions that might cause it? So I can try and see if they're responsible?

asked 19 Jul '13, 04:39

A%20Jefferiss's gravatar image

A Jefferiss
accept rate: 100%

Is it possible a service with same name already exists?

If your service name is common and customers may have a service with same name, you can use <getUniqueWindowsServiceName> action to generate unique display and service name. For example:

<getUniqueWindowsServiceName> <serviceName>foo</serviceName> <displayName>My Foo service</displayName> <selectedDisplayNameVariable>newDisplayName</selectedDisplayNameVariable> <selectedServiceNameVariable>newServiceName</selectedServiceNameVariable> </getUniqueWindowsServiceName> <createWindowsService> <program>${installdir}/myService.exe</program> <programArguments></programArguments> <serviceName>${newServiceName}</serviceName> <displayName>${newDisplayName}</displayName> <startType>auto</startType> <description>My Service</description> <dependencies></dependencies> <account>bitrock</account> <password>mySecRetPassword!!</password> </createWindowsService>

This is documented in more details in Windows Services section of InstallBuilder User Guide.


answered 22 Jul '13, 07:26

wojciechka's gravatar image

wojciechka ♦♦
accept rate: 26%

Excellent thanks, that looks like it was causing the problems. One thing I couldn't see in the user guide is the best practice to stopping and removing the service during uninstall.

Doing something like the following won't work because the uninstaller doesn't know about the variables...

<stopWindowsService> <serviceName>${newServiceName}/serviceName> <displayName>${newDisplayName}</displayName> <delay>15000</delay> </stopWindowsService> <deleteWindowsService> <serviceName>${newServiceName}</serviceName> <displayName>${newDisplayName}</displayName> </deleteWindowsService>

(24 Jul '13, 03:45) A Jefferiss

You can persist variables so they are accessible in uninstaller by using <setInstallerVariable> action with <persist> enabled - for example you can make the variables available in uninstaller by doing:

<setInstallerVariable> <name>newServiceName</name> <persist>1</persist> <value>${newServiceName}</value> </setInstallerVariable> <setInstallerVariable> <name>newDisplayName</name> <persist>1</persist> <value>${newDisplayName}</value> </setInstallerVariable>


answered 24 Jul '13, 04:13

wojciechka's gravatar image

wojciechka ♦♦
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 19 Jul '13, 04:39

Seen: 1,697 times

Last updated: 24 Jul '13, 04:14