Is it good to have windows service or console application?

徘徊边缘 提交于 2019-12-04 04:38:27
Dave New

You most likely want to use a windows service.

Benefits:

  • You can control the user (and the rights associated with this user account) which starts the process
  • An automatically started process means the desktop need to be on, not user logged, for the service to run
  • A policy on failure can be defined (try to restart n times run a specific program if fails)
  • A dependency can be defined (if you depend on other sevices)
  • You can wrap your script in an invisible window
  • You can easily start/stop/restart the script (net start <scriptname>)

Quoted from here: What is the benefit of developing the application as a windows service?

A running console app is not an option, as the others have stated.

If you just want the task run every x minutes the simplest option is a scheduled task using a console application.

A windows service has it's benefits, but is a little bit more complex to implement and deploy. However if your app needs to be 'always on' (e.g. need to react to external triggers, listen to message queue, ...), a windows service is the only option. As the others have said, the services infrastructure also provides more management capabilities, built-in integration with the event log, restart and failover options...

Windows service, because it does not require logged-in user.

I would say; Windows Services.

In that case (among other things) you don't need a user to be logged in, you can configure it in a matter to restart automatically if it shuts down for some reason and you (could) have extensive rights throughout the system.

Windows service generally. Console app will need to be restarted if the server reboots while a windows service can start automatically.

TheDaveJay

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

It allows you to debug as a console application and then install it as a windows service.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!