0

I have a windows service that i am installing using installutil.exe. How can i ensure that the service is automatically started immediately after installation. This is the service ProjectInstaller class

using System.ComponentModel;

namespace MedicalService_WindowsService
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            InitializeComponent();
        }
    }
}
leppie
  • 115,091
  • 17
  • 196
  • 297
StackTrace
  • 9,190
  • 36
  • 114
  • 202

1 Answers1

0

Use ServiceInstaller. Set the StartType to Automatic. This will ensure the service starts automatically, but does not actually starts the service. To do that, after the installation of the service is complete, start the service explicitly using ServiceController.Start().

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569