Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Can a windows service (possibly copied to multiple locations) be ran multiple times using different configurations (say for instance if the service supports commandline arguments)?

A service seems to be only installed once since the name has to be unique.

Is this scenario possible and what is the best way to do this?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

That is the basis for "svchost.exe", it is just given different service names and parameters.

This will help: http://support.microsoft.com/kb/137890

share|improve this answer
    
Interesting. A question though: the KB gives as an example that it makes a service from 'notepad' which inherently is not a service but just a plain exe. Does this trick also work for real services? –  reinier Sep 3 '10 at 13:20
    
AFAIK its meant to illustrate that ANY program can be run as a service.. although I would use some form of daemon myself. –  Grizly Sep 8 '10 at 10:59
    
Or to say it differently, starting multiple instances of a service is perfectly possible. It just depends on you setting it up, and the application actually supporting it. One semi-common example is MSDE. MSDE allows you to install several instances each as a separate service. –  Zoredache Sep 22 '10 at 7:03
    
Notepad doesn't actually work as a service anyway; it fails to tell the SCM that it is up and running in a timely fashion... –  SamB Nov 28 '10 at 18:17

If by multiple instances of the same service, you mean different instances of the same executable, then sure. You just need to create multiple "service" entries for it in the service table, with different names and different command line options.

Grizly seems to be talking about a different thing, where several services run inside the same process, typically an instance of svchost.exe. This necessitates that they use the same executable, though each service hosted by svchost appears to specify a DLL and (optionally) a ServiceMain entrypoint in the Parameters subkey of the service key. (Of course, the details of svchost.exe usage don't appear to be documented -- probably to keep people from trying to do crazy stuff like loading some version of the .NET framework into one of the system-critical instances, which would eventually lead to some other service trying to load a different version of the framework into the same one, and that would be a complete mess...)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.