Windows service

Last updated

In Windows NT operating systems, a Windows service is a computer program that operates in the background. [1] It is similar in concept to a Unix daemon. [1] A Windows service must conform to the interface rules and protocols of the Service Control Manager, the component responsible for managing Windows services. It is the Services and Controller app, services.exe, that launches all the services and manages their actions, such as start, end, etc. [2]

Contents

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. [3] [4]

Administration

Windows administrators can manage services via:

Services snap-in

The Services snap-in, built upon Microsoft Management Console, can connect to the local computer or a remote computer on the network, enabling users to: [1]

Command line

sc
Developer(s) Microsoft, ReactOS Contributors
Operating system Windows, ReactOS
Type Command
License Windows: Proprietary commercial software
ReactOS: GNU General Public License
Website docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/cc754599(v%3dws.11)

The command-line tool to manage Windows services is sc.exe. It is available for all versions of Windows NT. [7] This utility is included with Windows XP [8] and later [9] and also in ReactOS.

The sc command's scope of management is restricted to the local computer. However, starting with Windows Server 2003, not only can sc do all that the Services snap-in does, but it can also install and uninstall services. [9]

The sc command duplicates some features of the net command. [10]

The ReactOS version was developed by Ged Murphy and is licensed under the GPL. [11]

sc sub-commands
NameDescriptionWindows supportReactOS support
queryShow service statusYesYes
queryexShow extended service info (e.g. pid, flags)YesYes
startStart a serviceYesYes
pausePause a serviceYesYes
interrogateSend an INTERROGATE control request to a serviceYesYes
continueContinue a serviceYesYes
stopStop a serviceYesYes
configpermanently change the service configurationYesYes
descriptionChange a service descriptionYesYes
failureChange the actions taken by a service upon failureYesYes
failureflagYesNo
sidtypeYesNo
privsYesNo
managedaccountYesNo
qcShow the service config (e.g. dependencies, full path etc.)YesYes
qdescriptionQuery a service descriptionYesYes
qfailureYesNo
qfailureflagYesNo
qsidtypeYesNo
qprivsYesNo
qtriggerinfoYesNo
qpreferrednodeYesNo
qmanagedaccountYesNo
qprotectionYesNo
quserserviceYesNo
deleteDelete a serviceYesYes
createCreate a serviceYesYes
controlSend a control to a serviceYesYes
sdshowDisplay a service's security descriptor using SDDLYesYes
sdsetSets a service's security descriptor using SDDLYesYes
showsidYesNo
triggerinfoYesNo
preferrednodeYesNo
GetDisplayNameShow the service DisplayNameYesYes
GetKeyNameShow the service ServiceKeyNameYesYes
EnumDependShow the service DependenciesYesYes
bootYesNo
LockYesNo
QueryLockYesNo

Examples

The following example enumerates the status for active services & drivers. [12]

C:\>sc query 

The following example displays the status for the Windows Event log service. [12]

C:\>sc query eventlog 

PowerShell

The Microsoft.PowerShell.Management PowerShell module (included with Windows) has several cmdlets which can be used to manage Windows services:

Other management tools

Windows also includes components that can do a subset of what the snap-in, Sc.exe and PowerShell do. The net command can start, stop, pause or resume a Windows service. [21] 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.

Installation

Windows services are installed and removed via *.INF setup scripts by SetupAPI; an installed service can be started immediately following its installation, and a running service can be stopped before its deinstallation. [22] [23] [24]

Development

Writing native services

For a program to run as a Windows service, the program needs to be written to handle service start, stop, and pause messages from the Service Control Manager (SCM) through the System Services API. SCM is the Windows component responsible for managing service processes.

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. [25]

See also

Windows services
Concept

Related Research Articles

at (command) Task scheduling command on various operating systems

In computing, at is a command in Unix-like operating systems, Microsoft Windows, and ReactOS used to schedule commands to be executed once, at a particular time in the future.

A background process is a computer process that runs behind the scenes and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification.

<span class="mw-page-title-main">Windows Update</span> Software update distribution service for Microsoft Windows

Windows Update is a Microsoft service for the Windows 9x and Windows NT families of the Microsoft Windows operating system, which automates downloading and installing Microsoft Windows software updates over the Internet. The service delivers software updates for Windows, as well as the various Microsoft antivirus products, including Windows Defender and Microsoft Security Essentials. Since its inception, Microsoft has introduced two extensions of the service: Microsoft Update and Windows Update for Business. The former expands the core service to include other Microsoft products, such as Microsoft Office and Microsoft Expression Studio. The latter is available to business editions of Windows 10 and permits postponing updates or receiving updates only after they have undergone rigorous testing.

Windows Management Instrumentation (WMI) consists of a set of extensions to the Windows Driver Model that provides an operating system interface through which instrumented components provide information and notification. WMI is Microsoft's implementation of the Web-Based Enterprise Management (WBEM) and Common Information Model (CIM) standards from the Distributed Management Task Force (DMTF).

In computing, kill is a command that is used in several popular operating systems to send signals to running processes.

cmd.exe Command prompt program

Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2, eComStation, ArcaOS, Microsoft Windows, and ReactOS operating systems. On Windows CE .NET 4.2, Windows CE 5.0 and Windows Embedded CE 6.0 it is referred to as the Command Processor Shell. Its implementations differ between operating systems, but the behavior and basic set of commands are consistent. cmd.exe is the counterpart of COMMAND.COM in DOS and Windows 9x systems, and analogous to the Unix shells used on Unix-like systems. The initial version of cmd.exe for Windows NT was developed by Therese Stowell. Windows CE 2.11 was the first embedded Windows release to support a console and a Windows CE version of cmd.exe. The ReactOS implementation of cmd.exe is derived from FreeCOM, the FreeDOS command line interpreter.

<span class="mw-page-title-main">Windows Messenger service</span> Local network notification service for Microsoft Windows

Messenger service is a network-based system notification Windows service by Microsoft that was included in some earlier versions of Microsoft Windows.

<span class="mw-page-title-main">CHKDSK</span> System tool in DOS, OS/2 and Windows

In computing, CHKDSK is a system tool and command in DOS, Digital Research FlexOS, IBM/Toshiba 4690 OS, IBM OS/2, Microsoft Windows and related operating systems. It verifies the file system integrity of a volume and attempts to fix logical file system errors. It is similar to the fsck command in Unix and similar to Microsoft ScanDisk, which co-existed with CHKDSK in Windows 9x and MS-DOS 6.x.

<span class="mw-page-title-main">Windows Preinstallation Environment</span> Lightweight version of Microsoft Windows for deployment

Windows Preinstallation Environment is a lightweight version of Windows used for the deployment of PCs, workstations, and servers, or troubleshooting an operating system while it is offline. It is intended to replace MS-DOS boot disks and can be booted via USB flash drive, PXE, iPXE, CD, DVD, or hard disk. Traditionally used by large corporations and OEMs, it is now widely available free of charge via Windows Assessment and Deployment Kit (WADK).

In computing, SUBST is a command on the DOS, IBM OS/2, Microsoft Windows and ReactOS operating systems used for substituting paths on physical and logical drives as virtual drives.

In computing, regsvr32 is a command-line utility in Microsoft Windows and ReactOS for registering and unregistering DLLs and ActiveX controls in the operating system Registry. Despite the suffix "32" in the name of the file, there are both 32-bit and 64-bit versions of this utility. regsvr32 requires elevated privileges.

<span class="mw-page-title-main">Windows Boot Manager</span> Boot process used in modern Windows NT-based products

The Windows Boot Manager (BOOTMGR) is the bootloader provided by Microsoft for Windows NT versions starting with Windows Vista and Windows Server 2008. It is the first program launched by the BIOS or UEFI of the computer and is responsible for loading the rest of Windows. It replaced the NTLDR present in older versions of Windows.

The Client/Server Runtime Subsystem, or csrss.exe, is a component of the Windows NT family of operating systems that provides the user mode side of the Win32 subsystem. In modern versions of Windows, it is primarily involved with process and thread management, console window handling, side-by-side assembly loading and the shutdown process. Historically, it had also been responsible for window management and graphics rendering, however, these operations have been moved to kernel mode starting with Windows NT 4.0 to improve performance.

<span class="mw-page-title-main">Microsoft Drive Optimizer</span> Windows utility which defragments a hard drive

Microsoft Drive Optimizer is a utility in Microsoft Windows designed to increase data access speed by rearranging files stored on a disk to occupy contiguous storage locations, a technique called defragmentation. Microsoft Drive Optimizer was first officially shipped with Windows XP.

<span class="mw-page-title-main">Quick Assist</span> Microsoft Windows remote access feature

Quick Assist is a Microsoft Windows feature that allows a user to view or control a remote Windows computer over a network or the Internet to resolve issues without directly touching the unit. It is based on the Remote Desktop Protocol (RDP). It is complemented by Get Help, a feature introduced in Windows 10 that enables the user to contact Microsoft directly but does not allow for remote desktoping or screen sharing.

Windows Vista contains a range of new technologies and features that are intended to help network administrators and power users better manage their systems. Notable changes include a complete replacement of both the Windows Setup and the Windows startup processes, completely rewritten deployment mechanisms, new diagnostic and health monitoring tools such as random access memory diagnostic program, support for per-application Remote Desktop sessions, a completely new Task Scheduler, and a range of new Group Policy settings covering many of the features new to Windows Vista. Subsystem for UNIX Applications, which provides a POSIX-compatible environment is also introduced.

<span class="mw-page-title-main">Windows Task Scheduler</span> Computer application of Microsoft Windows

Task Scheduler is a job scheduler in Microsoft Windows that launches computer programs or scripts at pre-defined times or after specified time intervals. Microsoft introduced this component in the Microsoft Plus! for Windows 95 as System Agent. Its core component is an eponymous Windows service. The Windows Task Scheduler infrastructure is the basis for the Windows PowerShell scheduled jobs feature introduced with PowerShell v3.

<span class="mw-page-title-main">Shutdown (computing)</span> Remove power from a computers main components in a controlled way

To shut down or power off a computer is to remove power from a computer's main components in a controlled way. After a computer is shut down, main components such as CPUs, RAM modules and hard disk drives are powered down, although some internal components, such as an internal clock, may retain power.

diskpart Command line program

In computing, diskpart is a command-line disk partitioning utility included in Windows 2000 and later Microsoft operating systems, replacing its predecessor, fdisk. The command is also available in ReactOS.

net (command)

In computing, net is a command in IBM OS/2, Microsoft Windows, ReactOS and Greentea OS used to manage and configure the operating system from the command-line. It is also part of the IBM PC Network Program for DOS.

References

  1. 1 2 3 "Services overview". TechNet . Microsoft. Retrieved 29 March 2013.
  2. "Services". Microsoft Developer Network . Microsoft. Retrieved 29 March 2013.
  3. "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.
  4. "Services in Windows". MSDN . Microsoft. 18 October 2010. Retrieved 21 June 2013.
  5. "Start, stop, pause, resume, or restart a service". TechNet . Microsoft. Retrieved 29 March 2013.
  6. "ServiceInstaller.DelayedAutoStart Property (System.ServiceProcess)". Microsoft. Retrieved 28 November 2017See Remarks section{{cite web}}: CS1 maint: postscript (link)
  7. "How to create a Windows service by using Sc.exe". Support. Microsoft. 11 September 2011. Retrieved 29 March 2013.
  8. "Command-line reference A-Z: SC". TechNet . Microsoft . Retrieved 8 January 2014.
  9. 1 2 "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
  10. SC - Service Control - Windows CMD - SS64.com
  11. reactos/sc.c at master · reactos/reactos · GitHub
  12. 1 2 MS-DOS and Windows command line sc command
  13. "Get-Service". TechNet. Microsoft. Retrieved 29 March 2013.
  14. "New-Service". TechNet. Microsoft. Retrieved 29 March 2013.
  15. "Restart-Service". TechNet. Microsoft. Retrieved 29 March 2013.
  16. "Resume-Service". TechNet. Microsoft. Retrieved 29 March 2013.
  17. "Set-Service". TechNet. Microsoft. Retrieved 29 March 2013.
  18. "Start-Service". TechNet. Microsoft. Retrieved 29 March 2013.
  19. "Stop-Service". TechNet. Microsoft. Retrieved 29 March 2013.
  20. "Suspend-Service". TechNet. Microsoft. Retrieved 29 March 2013.
  21. "Start, stop, pause, resume, or restart a service". TechNet . Microsoft . Retrieved 8 January 2014.
  22. "INF AddService Directive". Microsoft. Retrieved 10 July 2017.
  23. "SetupInstallServicesFromInfSection function". MSDN. Microsoft. Retrieved 10 July 2017.
  24. "SetupInstallServicesFromInfSectionEx function". MSDN. Microsoft. Retrieved 10 July 2017.
  25. "How To Create a User-Defined Service". Support. Microsoft. Retrieved 29 March 2013.

Further reading