Windows service does not start after installation

I created one Windows service that sends emails every 30 minutes in C #. The service start mode is set to Automatic. But still the windows do not start automatically. I need to start manually by going to Services.msc and right-clicking the service and selecting start

+3
source share
4 answers

When StartMode is set to automatic, it means that it will start when Windows starts.

You can start the service yourself in a custom action in your installer. I assume that you already have the Installer class, and that this is already a custom action for your installation project, since the installation is installed but does not start.

Override the OnAfterInstall method in the Installer class, and you can start the service as follows:

protected override void OnAfterInstall(IDictionary savedState) {
    base.OnAfterInstall(savedState);

    ServiceController sc = new ServiceController("MyServiceName");
    sc.Start();
}

However, the planned task is a good way.

+5
source

Why put yourself at all the overhead and suffer from troubleshooting and Windows service support for time application or polling? For Windows, support was built in. Just create a simple console application. Run it as a scheduled task.

. , . , , .

, Windows SOA. / SOA. , , . ~ 20-30 win, n- , , 10 . , , , . .

+4

. , TCP/IP , , . Windows , OnStart() .

, , "" . , , , , .

: . , , 30 .

+2

Do you install it using installutil? You are right, it does not start the service, even if it is set to automatic. If I were you, I would provide a batch file that calls installutil and then also starts "net start". Or, if you use other types of installation, they should also provide this capability.

0
source

Source: https://habr.com/ru/post/1781852/


All Articles