Create a Windows Service Installer - CSharp Operating System

CSharp examples for Operating System:Windows

Description

Create a Windows Service Installer


using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;

[RunInstaller(true)]
class MainClass
{
    public static void Main()
    {
        ServiceProcessInstaller ServiceExampleProcess = new ServiceProcessInstaller();
        ServiceExampleProcess.Account = ServiceAccount.LocalSystem;

        ServiceInstaller ServiceExampleInstaller = new ServiceInstaller();
        ServiceExampleInstaller.DisplayName = "Service Example";
        ServiceExampleInstaller.ServiceName = "book2s.com Service";
        ServiceExampleInstaller.StartType = ServiceStartMode.Automatic;

        Installers.Add(ServiceExampleInstaller);
        Installers.Add(ServiceExampleProcess);
    }
}

Related Tutorials