Start windows service on install without setup project

Volearix

I have developed a windows service, but need it to start automatically on install. Problem is that every tutorial I found is showing me through the Setup Project. There is a fantastic 3 part tutorial HERE that I used to convert my app to a service, but I don't have the Setup Project in my other project types. Can I do this programatically or is there a way I can get the Setup Project project type?

Sakthivel

In your Installer class, add a handler for the AfterInstall event. You can then call the ServiceController in the event handler to start the service.

public ServiceInstaller()
{
    //... Installer code here
    this.AfterInstall += new InstallEventHandler(ServiceInstaller_AfterInstall);
}

void ServiceInstaller_AfterInstall(object sender, InstallEventArgs e)
{
    using (ServiceController sc = new ServiceController(serviceInstaller.ServiceName))
    {
         sc.Start();
    }
}

Now when you run InstallUtil on your installer it will install and then start up the service.

MSDN link for more details

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

C# How to create a Setup project for a Windows Service to install it automagically?

From Dev

Upgrade (unisntall/install) Windows Service using InstallShield Setup Project

From Dev

ServiceStack as Windows Service with Razor - Setup Project

From Dev

WiX MSI install Windows service without starting it

From Dev

Windows service fails to install through msi setup in few machines

From Dev

How do I install a windows service that runs as an administrator without GUI?

From Dev

Is it possible to install Bonjour Service without the Print Services on Windows?

From Dev

Install a service without template

From Dev

Install a service without template

From Dev

React without webpack project setup

From Dev

Can I create one project with Application(GUI) and Windows Service and have one setup which installs both?

From Dev

Can I create one project with Application(GUI) and Windows Service and have one setup which installs both?

From Dev

install application during project start

From Dev

Install windows service with PsExec?

From Dev

MongoDB Service Will Not Start After Initial Setup

From Dev

Start Service at boot without activity

From Dev

Install Windows Update file (*.msu) without having Windows update service activated

From Dev

Project setup don't create service

From Dev

Squirrel for Windows - Setup/Install fails on Windows 7

From Dev

Azure Cloud Service Project opens two Browser Windows on Start when Debugging

From Dev

Get Windows service start type?

From Dev

Start Windows Service in C#

From Dev

Powershell - Start Windows service with a parameter

From Dev

Start/Stop Windows Service with buttons

From Dev

Start/Stop Windows Service with buttons

From Dev

Windows service can't start

From Dev

Debugging a Windows Service - Prevent Cannot Start Service

From Dev

Elastic Kibana - install as windows service

From Dev

Register autofac in windows service project

Related Related

  1. 1

    C# How to create a Setup project for a Windows Service to install it automagically?

  2. 2

    Upgrade (unisntall/install) Windows Service using InstallShield Setup Project

  3. 3

    ServiceStack as Windows Service with Razor - Setup Project

  4. 4

    WiX MSI install Windows service without starting it

  5. 5

    Windows service fails to install through msi setup in few machines

  6. 6

    How do I install a windows service that runs as an administrator without GUI?

  7. 7

    Is it possible to install Bonjour Service without the Print Services on Windows?

  8. 8

    Install a service without template

  9. 9

    Install a service without template

  10. 10

    React without webpack project setup

  11. 11

    Can I create one project with Application(GUI) and Windows Service and have one setup which installs both?

  12. 12

    Can I create one project with Application(GUI) and Windows Service and have one setup which installs both?

  13. 13

    install application during project start

  14. 14

    Install windows service with PsExec?

  15. 15

    MongoDB Service Will Not Start After Initial Setup

  16. 16

    Start Service at boot without activity

  17. 17

    Install Windows Update file (*.msu) without having Windows update service activated

  18. 18

    Project setup don't create service

  19. 19

    Squirrel for Windows - Setup/Install fails on Windows 7

  20. 20

    Azure Cloud Service Project opens two Browser Windows on Start when Debugging

  21. 21

    Get Windows service start type?

  22. 22

    Start Windows Service in C#

  23. 23

    Powershell - Start Windows service with a parameter

  24. 24

    Start/Stop Windows Service with buttons

  25. 25

    Start/Stop Windows Service with buttons

  26. 26

    Windows service can't start

  27. 27

    Debugging a Windows Service - Prevent Cannot Start Service

  28. 28

    Elastic Kibana - install as windows service

  29. 29

    Register autofac in windows service project

HotTag

Archive