12

I created one windows serives

It gets the name of the service from web config file.

I used the below link for getting value from webconfig. http://www.codeproject.com/KB/dotnet/MultipleInstNetWinService.aspx

for installing my windows service,i just click the icon and install again, i change the value in config file and rebulid my application.

again i try to install, it shows error like the specified service already exist.

How to install multiple instance of same windows service?

Thanks, Pooja

Pratik
  • 11,534
  • 22
  • 69
  • 99
Pooja
  • 495
  • 3
  • 9
  • 25

5 Answers5

16

I needed to do this for a quick demo of a service running with different parameters.

I copied the directory containing the service exe and then used the sc create command to setup the second service.

sc create "[NewServiceName]" binPath="[PathToCopiedServiceDirectory]"

How to create a windows service using the Sc.exe command

Naeem Sarfraz
  • 7,360
  • 5
  • 37
  • 63
  • 1
    Make sure that you include the actual service EXE file name in the [PathToCopiedServiceDirectory] value for binPath, otherwise the service will point to the directory and you'll get an "Access Denied" error when you try to start the service. – Sean Chase Apr 19 '17 at 00:33
13
sc create MyService binPath= "MyService.exe" DisplayName= "MyService"  
sc description MyService "My description"

Reference: http://support.microsoft.com/kb/251192

Followed marked answer and wasted an hour. it was simple using sc create command

dotnetom
  • 24,551
  • 9
  • 51
  • 54
mongesh madhavan
  • 583
  • 4
  • 16
9

You need to copy your service executable to a separate directory and use InstallUtil.exe to give it a different service name.

It sounds like you missed this section in the linked article

From a command prompt, you'll need to use InstallUtil to install both instances of your service. For instructions on how to use InstallUtil, see Installer Tool (InstallUtil.exe). Once you're done installing the service instances, you'll have something like the services console above where Service Instance 1 and Service Instance 2 are created from the same executable, only installed from different directory locations with a different service name.

shamp00
  • 11,106
  • 4
  • 38
  • 81
  • i try to install using command propemt. it shows installutil is not recodized internal or external command – Pooja Jan 04 '12 at 10:49
  • It's part of the .NET Framework and it's available in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727. – shamp00 Jan 04 '12 at 11:12
  • i used vs2010 command prompt and install windows service, it shows the service is already exist. but i change the service name in config file. – Pooja Jan 04 '12 at 11:22
  • Did you install the service from a different directory than the first instance? It must be in a different directory. Hope that helps. – shamp00 Jan 04 '12 at 11:30
  • You should also look at the answer by @NaeemSarfraz below as well as [this issue](http://stackoverflow.com/questions/1279383/installing-multiple-instances-of-the-same-windows-service-on-a-server) for how to use sc instead of InstallUtil. – shamp00 Jan 04 '12 at 11:52
0

I had to change the service name in the file "ProjectInstaller.Designer.cs" in visual studio and recompile. Hope it helps.

-5

Run the asp.net command prompt as administrator and then use the command - installutil "c:\abc\xyz.exe".

If your service is already install then you can uninstall first using the command - installutil \u "c:\abc\xyz.exe"

CuriousMind
  • 118
  • 1
  • 1
  • 10