如何安装同一个Windows服务的多个实例

时间:2012-01-04 10:11:46

标签: .net windows windows-services

我创建了一个Windows服务器

它从Web配置文件中获取服务的名称。

我使用以下链接从webconfig获取值。 http://www.codeproject.com/KB/dotnet/MultipleInstNetWinService.aspx

安装我的Windows服务,我只需单击图标并安装即可 再一次,我改变了配置文件中的值并反驳了我的应用程序。

我再次尝试安装,它显示已存在的指定服务错误。

如何安装同一个Windows服务的多个实例?

谢谢, POOJA

5 个答案:

答案 0 :(得分:14)

我需要这样做才能快速演示使用不同参数运行的服务。

我复制了包含service exe的目录,然后使用sc create命令设置第二个服务。

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

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

答案 1 :(得分:9)

sc create MyService binPath= "MyService.exe" DisplayName= "MyService"  
sc description MyService "My description"

参考:http://support.microsoft.com/kb/251192

跟着标记的答案,浪费了一个小时。使用sc create命令很简单

答案 2 :(得分:8)

您需要将服务可执行文件复制到单独的目录,并使用InstallUtil.exe为其提供不同的服务名称。

听起来你错过了the linked article

中的这一部分
  

在命令提示符下,您需要使用InstallUtil来安装它们   您的服务实例。有关如何使用InstallUtil的说明,   见Installer Tool (InstallUtil.exe)。一旦你完成了安装   服务实例,你会有类似服务控制台的东西   上面创建了 Service Instance 1 Service Instance 2   相同的可执行文件,仅从不同的目录位置安装   使用不同的服务名称。

答案 3 :(得分:0)

我不得不在visual studio中的“ProjectInstaller.Designer.cs”文件中更改服务名称并重新编译。希望它有所帮助。

答案 4 :(得分:-5)

以管理员身份运行asp.net命令提示符,然后使用命令 - installutil“c:\ abc \ xyz.exe”。

如果您的服务已经安装,那么您可以先使用命令卸载 - installutil \ u“c:\ abc \ xyz.exe”