Windows Console App vs Service

installeroperating systemsserviceswindows

My Situation

I work for a company that builds software for many other companies.
When I learned installers weren't built-in with VS2012, I was curious how to deploy.
So far, I have just been dropping .exes on our clients servers using PowerShell scripts.
Now I need a full-blown Windows service.

I have seen many example of how to run services via a console application:
https://stackoverflow.com/questions/7764088/net-console-application-as-windows-service

I could easily use sc.exe to create a service based on a console application like this.
I have no idea how Windows would handle Start/Stop/Restart, though.

The Question

This has made me curious what the relationship between console applications and services is in the Window's world. Are services just console applications with hooks to allow the OS to call start and stop? Or are services completely different?

A long time ago, I thought WinForms and console applications were completely different. After messing around in Win32, I realized they were the same thing.

My Hopes

I am hoping services are just console apps, like WinForms, and that I can tap into the Start/Stop capabilities directly in .NET. The built-in installer projects were pretty awful, so I don't feel too bad for copying .exes to the server.

Best Answer

I wouldn't say that a console application is totally different from a windows service. They are both hosts to execute code. That being said, there are some key differences:

  • A service can run even if a user is not logged into the PC.
  • A service can easily be configured to run in the context of a high-authority accounts such as Network Service or Local System.
  • A service comes built in with hooks for starting, stopping, restarting, and pausing while running.
  • A service doesn't have an attached console, it can't print anything to stdout but has to use system logging instead (credit to Martin)
Related Topic