Installing multiple instances of the same windows service on a server Installing multiple instances of the same windows service on a server windows windows

Installing multiple instances of the same windows service on a server


Have you tried the sc / service controller util? Type

sc create

at a command line, and it will give you the help entry. I think I've done this in the past for Subversion and used this article as a reference:

http://svn.apache.org/repos/asf/subversion/trunk/notes/windows-service.txt


  sc create [servicename] binpath= [path to your exe]

This solution worked for me.


You can run multiple versions of the same service by doing the following:

1) Copy the Service executable and config to its own folder.

2) Copy Install.Exe to the service executable folder (from .net framework folder)

3) Create a config file called Install.exe.config in the service executable folderwith the following contents (unique service names):

<?xml version="1.0" encoding="utf-8" ?><configuration>  <appSettings>    <add key="ServiceName" value="The Service Name"/>    <add key="DisplayName" value="The Service Display Name"/>  </appSettings></configuration>

4) Create a batch file to install the service with the following contents:

REM InstallInstallUtil.exe YourService.exepause

5) While your there, create an uninstall batch file

REM UninstallInstallUtil.exe -u YourService.exepause

EDIT:

Note sure if I missed something, here is the ServiceInstaller Class (adjust as required):

using System.Configuration;namespace Made4Print{    partial class ServiceInstaller    {        /// <summary>        /// Required designer variable.        /// </summary>        private System.ComponentModel.IContainer components = null;        private System.ServiceProcess.ServiceInstaller FileProcessingServiceInstaller;        private System.ServiceProcess.ServiceProcessInstaller FileProcessingServiceProcessInstaller;        /// <summary>         /// Clean up any resources being used.        /// </summary>        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>        protected override void Dispose(bool disposing)        {            if (disposing && (components != null))            {                components.Dispose();            }            base.Dispose(disposing);        }        #region Component Designer generated code        /// <summary>        /// Required method for Designer support - do not modify        /// the contents of this method with the code editor.        /// </summary>        private void InitializeComponent()        {            this.FileProcessingServiceInstaller = new System.ServiceProcess.ServiceInstaller();            this.FileProcessingServiceProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();            //             // FileProcessingServiceInstaller            //             this.FileProcessingServiceInstaller.ServiceName = ServiceName;            this.FileProcessingServiceInstaller.DisplayName = DisplayName;            //             // FileProcessingServiceProcessInstaller            //             this.FileProcessingServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;            this.FileProcessingServiceProcessInstaller.Password = null;            this.FileProcessingServiceProcessInstaller.Username = null;            //             // ServiceInstaller            //             this.Installers.AddRange(new System.Configuration.Install.Installer[] { this.FileProcessingServiceInstaller, this.FileProcessingServiceProcessInstaller });        }        #endregion        private string ServiceName        {            get            {                return (ConfigurationManager.AppSettings["ServiceName"] == null ? "Made4PrintFileProcessingService" : ConfigurationManager.AppSettings["ServiceName"].ToString());            }        }        private string DisplayName        {            get            {                return (ConfigurationManager.AppSettings["DisplayName"] == null ? "Made4Print File Processing Service" : ConfigurationManager.AppSettings["DisplayName"].ToString());            }        }    }}