4

I want to run multiple instances of a Windows Service installed on a server without installing it again.

How is this possible?

3
  • 2
    Did you tried anything? Commented Apr 3, 2013 at 10:52
  • 1
    It's not possible. You could create differently named services (perhaps with different command line parameters), or have a single windows service that spawns other processes, but you can't do what you've described in your question - it just doesn't make sense. Please can you edit your question to describe the background to your problem, and exactly what you are hoping to achieve? Commented Apr 3, 2013 at 10:53
  • 2
    You might want to rethink this and have one windows service that has multiple threads running. Commented Apr 3, 2013 at 10:54

1 Answer 1

7

A service "installation" is really just adding a mapping between a name, an executable, and a few other bits of metadata. A service, once installed, is either running (once), or it isn't. To have multiple instances running as services, they would have to be registered with different names, which basically means installing it multiple times. That does not, however, mean that you need multiple different copies of the executable.

The way I do it is to subclass Installer such that it creates a ServiceInstaller and ServiceProcessInstaller, and gives a ServiceName (at runtime, via the custom installer) to the ServiceInstaller instance, then use ManagedInstallerClass at runtime - basically making a standalone exe capable of installing and uninstalling itself as a service (as many times as you like), using command-line parameters to specify the name.

Sign up to request clarification or add additional context in comments.

3 Comments

I still wonder why TS wants to do this and whether it's the best idea.
Here's more details. Usefull stuff. journalofasoftwaredev.wordpress.com/2008/07/16/…
Can you post the Installer Subclass please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.