Is it good to have a Windows service or a console application?

I have a task table in my db. I want to read data from this table and run tasks. Which one is better, be it as a Windows service or as a running console application. The server on which it will be launched will not be completed

+7
source share
6 answers

Most likely you want to use the Windows service.

Benefits:

  • You can control the user (and the rights associated with this user account) that starts the process
  • An automatically starting process means that the desktop must be turned on, not registered by the user, to start the service
  • You can define a failure policy (try restarting n once, run a specific program if it does not work)
  • You can define a dependency (if you are dependent on other functions)
  • You can wrap the script in an invisible window
  • You can easily start / stop / restart the script ( net start <scriptname> )

Quote: What is the advantage of developing an application as a Windows service?

+8
source

The console application is not an option, as others have stated.

If you want the task to run every x minutes, the easiest option is to schedule the task using the console application.

The Windows service has advantages, but is a little more difficult to implement and deploy. However, if your application should be "always on" (for example, you need to respond to external triggers, listen to the message queue, ...), the only way is the Windows service. As others noted, the service infrastructure also provides more management capabilities, built-in integration with the event log, reboot and fault tolerance ...

+3
source

Windows service because it does not require a login.

0
source

I would say; Windows Services

In this case (among other things) you do not need a user to enter the system, you can configure it in case of a reboot automatically, if it disconnects for some reason, and you (can) have extensive rights throughout the system.

0
source

Windows service in general. The console application needs to be restarted if the server restarts while the Windows service can start automatically.

0
source

You should see: https://github.com/thedavejay/Self-Installing-Windows-Service

This allows you to debug a console application and then install it as a Windows service.

0
source

All Articles