There are many instances in which a developer might want to develop an application that runs as a Windows Service, and there are some distinct advantages to doing so. At Stackify, we aim to help make you a better developer in every possible scenario, and that’s why we built Prefix to help you debug Windows Services (and tons of other stuff, too).
Here’s a look at what Windows Services are, how it works, examples of Windows Services, and options for developers for configuring applications to run as a Service.
Definition of Windows Services
Windows Services are a core component of the Microsoft Windows operating system and enable the creation and management of long-running processes.
Unlike regular software that is launched by the end user and only runs when the user is logged on, Windows Services can start without user intervention and may continue to run long after the user has logged off. The services run in the background and will usually kick in when the machine is booted. Developers can create Services by creating applications that are installed as a Service, an option ideal for use on servers when long-running functionality is needed without interference with other users on the same system.
The services manage a wide variety of functions including network connections, speaker sound, data backup, user credentials and display colors. Windows Services perform a similar function as UNIX daemons.
What is the Windows Services Control Manager?
Windows Services are managed via the Services Control Manager panel. The panel shows a list of services and for each, name, description, status (running, stopped or paused) and the type of service. Double clicking on a service reveals its properties in greater detail. You can stop, pause, start, delay start, or resume each service as appropriate. You can also modify the start mechanism (Manual or Automatic) or specify an account.
Windows Services broadly fall into three categories depending on the actions and applications they control: Local Services, Network Services and System. Third party applications such as antivirus software may also install their own services.
Services can be deleted by a user with administrative privileges, but as doing so can render the operating system unstable, it should be done only when necessary and with caution.
Differences between Windows Services and Regular Applications
- Launch Mechanism – A regular application is manually launched by the end user from the desktop or Start Menu. Examples include web browsers, document editing software and PDF readers. Windows Services start when the machine is switched on. Note however that regular applications can be added to the Startup folder in the Start Menu in which case they would start automatically once the operating system startup is complete.
- User Interface – Unlike regular applications, Windows Services do not have a user interface; they run in the background and the user does not directly interact with them. A Windows Service does not stop when a user logs off the computer; a regular application will.
- Multiple Instances – Only one instance of a Windows Service runs on a device. Regular applications can allow multiple copies if several users are logged into the same machine.
- Administrator Rights – Windows Services usually run under administrative privileges even when a non-administrator user is logged in and using the computer. The average Windows Service has more control over the machine compared to a regular application.
Examples of Windows Services
- Active Directory Service – Active Directory is a service Microsoft developed for Windows networks. It is included by default in most Microsoft Windows Server systems. Active Directory oversees centralized domain management and identity-related functions.
- Prefetch and Superfetch Service – Speeds up operating system and application startup by caching to RAM frequently used files, libraries and application components. It does this by monitoring application usage and behavior.
- Background Intelligent Transfer Service – This service facilitates throttled, prioritized and asynchronous file transfer between machines via idle bandwidth. It plays a key role in the delivery of software updates from servers to clients as well as in the transfer of files on Microsoft’s instant messaging applications.
- DNS Client Service – This service resolves domain names to IP addresses and locally caches this data.
- Computer Browser Service – It allows users to easily locate shared resources on neighboring computers. All information is aggregated on one of the computers (referred to as the Master Browser) and other computers contact this machine for information on shared resources.
- Internet Connection Sharing (ICS) Service – ICS enables the use of one device connected to the internet as an access point for other devices. Access could be through Ethernet broadband, cellular service or other gateway.
- Routing and Remote Access Service – This service makes it possible to create applications that manage the remote access and routing capabilities of the Windows operating system. It allows the machine to act as a network router.
Developers often use Services for functions that are necessary to run in the background, such as the ability to monitor performance data and react to specified thresholds. Services can also be created as Microsoft Visual Studio projects, developing code that specifies what commands can be sent to the service as well as what actions are taken on receipt of those commands. For more specifics on using Visual Studio projects to create Services, check out our recent post on how to create .NET Core Windows Services with Visual Studio 2017.
After creating and building an application, you can install it as a service by running the command-line utility InstallUtil.exe, then passing the path to the Service’s executable file. Then, use the Services Control Manager to configure the Service. Alternatively, services can be configured using the Services node in Server Explorer or with the ServiceController class. Check out our sample Windows Services project on GitHub for examples of timer-based events, queue processing, and job scheduling – some of the more popular uses for Windows Services.
Additional Resources and Tutorials on Windows Services
For more information on Windows Services, including helpful Windows Services tutorials and guides, visit the following resources:
- Walkthrough: Creating a Windows Service Application in the Component Designer
- Develop and Install a Windows Service in C#
- Tutorial to create a simple Windows Service with sample example in C# and VB.Net
- Simple Windows Service Sample
- Create Windows Service in Visual Studio [C#]
- Americaneagle.com and ROC Commerce stay ahead with Retrace - September 25, 2020
- Stackify’s New Pricing: Everything you need to know - September 9, 2020
- INNOVATORS VS COVID 19 Matt Watson, the CEO at Stackify, advises Entrepreneurs to focus on the things that make them happy, regardless if work is a giant dumpster fire - September 2, 2020
- Stackify Joins the 2020 Inc. 5000 List of Fastest-Growing Companies - August 25, 2020
- Stackify Changes Pricing Model for Retrace - July 30, 2020