The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation


Top 10 differences between a Windows Service and a regular application

What's the difference between an application and a service?

First, let’s start with some definitions…

What is a regular application?

A regular application is one that you start and run on your Windows desktop. You launch it from a desktop icon, by double-clicking an associated document, or by typing its name at a command prompt. Examples include Microsoft Excel, Adobe Reader, Google Chrome and virtually any other program you consciously interact with on your PC. These are the programs that you know, love and use every day — the ones that make your computer a remarkably powerful tool.

What is a windows service?

A Windows Service is a special program designed to “plug into” Windows. It typically chugs along doing its work in the background, never revealing itself, with little or no attention from anyone using the PC. It turns out that a whole host of these invisible workers are necessary to make your PC work smoothly! For example, the Print Spooler windows service ensures that your documents arrive at the printer, while the Workstation service makes the Internet available for all applications. Important tasks indeed!

What’s the difference?

So with those basics in place, here are the 10 most important ways that a windows service differs from a regular application:

  1. A windows service can start automatically at boot, without anyone having to log on. A regular application only runs when a user is logged in. This key distinction makes the windows service framework the better choice for software that must run 24×7, surviving the inevitable reboot along the way.

  2. A windows service won’t exit when you or anyone else logs off the PC. A regular application will stop when you log out.

  3. Windows services don’t run visibly on your desktop (not since Vista). They are confined to the isolated Session 0 and can not (usually) show their windows or tray icons to anyone logging into the PC. This restriction makes it very difficult for a windows service to interact with someone using the computer and consequently Microsoft strongly discourages implementing GUI services.

  4. A windows service can be easily started or stopped from the command line using the NET or SC commands. This capability is a boon to sysadmins and technical folks, who can conveniently manage a service’s lifetime through unattended, administrative scripts.

    Starting/stopping a service with the NET Command

  5. Only a single instance of a windows service can be started at any time. That single copy must serve all users on the PC. This is very different than a regular application, which typically permits multiple copies, especially when several people are logged in.

  6. Services typically run in the Local System account, which has administrative powers over many aspects of the PC. Thus your average service will have more rights and control over your computer than your typical application running in the context of a regular user’s account.

    Services Log On tab

  7. When run as LocalSystem, a service has access to UNC paths (for example, “\\server\data”) but cannot access mapped drive letters. You should run the service in a regular user account to access network drives, and even then the service may have to map drives explicitly (for example, with the NET USE command) to gain access.

  8. All windows services support sophisticated recovery options for when they stop unexpectedly. You can restart the service, run a command line or even reboot the computer.

    Windows Service Recovery Tab

  9. While each regular application is backed by a single, unique process, it is possible for many services to share a single running process. This situation makes it possible for some services to start rapidly and make efficient use of resources — important characteristics for critical components that must always be available.

  10. A windows service must contain special code to respond to instructions from the Windows Service Control Manager (SCM). For the technical folks, this means implementing the ServiceMain (or equivalent) entry point in your application.

Posted in Windows Services | Tagged , , , | 1 Comment

One Response to Top 10 differences between a Windows Service and a regular application

  1. Eun Sirmons says:

    Only wanna admit that this is handy, Thanks for taking your time to write this.

Leave a Reply

Your email address will not be published. Required fields are marked *