This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)(Learn how and when to remove this template message)
In Windows NT operating systems, a Windows service is a computer program that operates in the background. It is similar in concept to a Unix daemon. A Windows service must conform to the interface rules and protocols of the Service Control Manager, the component responsible for managing Windows services.
Windows services can be configured to start when the operating system is started and run in the background as long as Windows is running. Alternatively, they can be started manually or by an event. Windows NT operating systems include numerous services which run in context of three user accounts: System, Network Service and Local Service. These Windows components are often associated with Host Process for Windows Services. Because Windows services operate in the context of their own dedicated user accounts, they can operate when a user is not logged on.
Prior to Windows Vista, services installed as an "interactive service" could interact with Windows desktop and show a graphical user interface. In Windows Vista, however, interactive services are deprecated and may not operate properly, as a result of Windows Service hardening.
Windows administrators can manage services via:
- The Services snap-in (found under Administrative Tools in Windows Control Panel)
- Windows PowerShell
- view a list of installed services along with service name, descriptions and configuration
- start, stop, pause or restart services
- specify service parameters when applicable
- change the startup type. Acceptable startup types include:
- Automatic: The service starts at system logon.
- Automatic (Delayed): The service starts a short while after the system has finished starting up. This option was introduced in Windows Vista in an attempt to reduce the boot-to-desktop time. However, not all services support delayed start.
- Manual: The service starts only when explicitly summoned.
- Disabled: The service is disabled. It will not run.
- change the user account context in which the service operates
- configure recovery actions that should be taken if a service fails
- inspect service dependencies, discovering which services or device drivers depend on a given service or upon which services or device drivers a given service depends
- export the list of services as a text file or as a CSV file
Sc.exe's scope of management is restricted to the local computer. However, starting with Windows Server 2003, not only can Sc.exe do all that the Services snap-in does, but it can also install and uninstall services.
Windows PowerShell can intrinsically manage Windows services via the following cmdlets:
Other management tools
In addition to the snap-in, Sc.exe and PowerShell, Windows also includes components that can do a subset of what the trio can do. Net.exe can start, stop, pause or resume a Windows service. In Windows Vista and later, Windows Task Manager can show a list of installed services and start or stop them. MSConfig can enable or disable (see startup type description above) Windows services.
Writing native services
A Windows service is created using development tools such as Microsoft Visual Studio or Embarcadero Delphi. In order to be a Windows service, a program needs to be written in such a way that it can handle start, stop, and pause messages from the Service Control Manager. Service Control Manager is a component of Windows which is responsible for starting and stopping services.
Wrapping applications as a service
The Windows Resource Kit for Windows NT 3.51, Windows NT 4.0 and Windows 2000 provides tools to control the use and registration of services:
SrvAny.exe acts as a service wrapper to handle the interface expected of a service (e.g. handle service_start and respond sometime later with service_started or service_failed) and allow any executable or script to be configured as a service.
Sc.exe allows new services to be installed, started, stopped and uninstalled.
- Windows services
- Background process
- Operating system service management
- Service wrapper
- "Services overview". TechNet. Microsoft. Retrieved 29 March 2013.
- "Services". Microsoft Developer Network. Microsoft. Retrieved 29 March 2013.
- "New Elevation PowerToys for Windows Vista". TechNet Magazine. Microsoft. June 2008. Retrieved 21 June 2013.
The service CmdAsSystem is configured as interactive whose support is being deprecated. The service may not function properly. The problem is that this script tries to create and start an interactive service. Interactive services will not function correctly due to Session 0 Isolation in Windows Vista.
- "Services in Windows". MSDN. Microsoft. 18 October 2010. Retrieved 21 June 2013.
- "Start, stop, pause, resume, or restart a service". TechNet. Microsoft. Retrieved 29 March 2013.
- "ServiceInstaller.DelayedAutoStart Property (System.ServiceProcess)". Microsoft. Retrieved April 2013See Remarks section
- "How to create a Windows service by using Sc.exe". Support. Microsoft. 11 September 2011. Retrieved 29 March 2013.
- "Command-line reference A-Z: SC". TechNet. Microsoft. Retrieved 8 January 2014.
- "Command-Line Reference: Sc". TechNet. Microsoft. Retrieved 8 January 2014.
Windows 7, Windows 8, Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Vista
- "Get-Service". TechNet. Microsoft. Retrieved 29 March 2013.
- "New-Service". TechNet. Microsoft. Retrieved 29 March 2013.
- "Restart-Service". TechNet. Microsoft. Retrieved 29 March 2013.
- "Resume-Service". TechNet. Microsoft. Retrieved 29 March 2013.
- "Set-Service". TechNet. Microsoft. Retrieved 29 March 2013.
- "Start-Service". TechNet. Microsoft. Retrieved 29 March 2013.
- "Stop-Service". TechNet. Microsoft. Retrieved 29 March 2013.
- "Suspend-Service". TechNet. Microsoft. Retrieved 29 March 2013.
- "Start, stop, pause, resume, or restart a service". TechNet. Microsoft. Retrieved 8 January 2014.
- "How To Create a User-Defined Service". Support. Microsoft. Retrieved 29 March 2013.
- Savill, John (5 March 1999). "What are the ErrorControl, Start and Type values under the Services subkeys?". Windows IT Pro. Penton Media. Retrieved 29 March 2013.
- David B. Probert, Windows Service Processes
- Windows Sysinternals: Autoruns for Windows v13.4—An extremely detailed query of services
- Windows Service Manager Tray - To help you to use Windows Services