Fact-checked by Grok 2 weeks ago

Windows service

A Windows service is a long-running application in the Windows operating system that runs in the background without a , enabling automated tasks such as system maintenance, networking, or server operations even when no user is logged on. Formerly known as NT services, these applications operate in their own dedicated Windows sessions and are designed to start automatically at system boot or in response to specific triggers, providing reliable, non-interactive functionality for both client and server environments. Windows services are centrally managed by the , a component of the operating system that maintains a database of installed services and driver services, handling their startup, configuration, pausing, resumption, and shutdown through a secure interface. Services can be configured to run under specific user accounts for security purposes, with administrators able to customize access controls and startup behaviors via tools like the Services console or command-line utilities. There are two primary types: Win32 own process services, which run independently in their own process, and Win32 share process services, which share a process with other services to optimize resource usage. Developers create Windows services using frameworks like .NET, where applications inherit from the ServiceBase class and are installed via utilities such as InstallUtil.exe, or through Win32 APIs for lower-level control. This architecture ensures services remain isolated from user sessions, enhancing system stability and security, while supporting custom commands for advanced management.

Overview

Definition and Purpose

A Windows service is a long-running that runs in its own Windows session without a , managed by the operating system to perform background tasks supporting applications, system components, or hardware. These services, originally known as NT services and based on the Win32 subsystem, were introduced in to enable reliable, persistent operations independent of user sessions. The primary purpose of Windows services is to handle essential system functions that operate continuously, such as networking via the DHCP Client service for automatic IP address assignment, security scanning through the service, and device management for peripherals like printers or storage. In contrast to interactive user applications, services launch at system startup, persist across user logons and logoffs, and are controlled centrally to ensure stability and resource efficiency. Key characteristics include execution in Session 0 for isolation from user processes—a feature implemented starting with to enhance security by preventing services from interacting directly with user desktops—and non-interactive operation by default to avoid disruptions. Services also support configurable startup types: Automatic for boot-time initiation, Manual for on-demand activation, and Disabled to prevent execution entirely. Over time, Windows services have evolved from their foundations to incorporate modern enhancements in and 11, such as improved integration with cloud-based features for hybrid environments. The oversees their lifecycle and interactions.

Historical Development

Windows services were first introduced with in 1993 as Win32 services, providing a mechanism for long-running background processes managed by the (SCM), which replaced terminate-and-stay-resident (TSR) programs in and similar background tasks in equivalents. These services operated in user mode, enabling reliable execution independent of user logons and supporting enterprise features like networked printing and from the outset. In , released in 1996, service stability was enhanced through integration of the user interface and subsequent service packs, such as Service Pack 4 in 1998, which addressed reliability issues in core OS components including service hosting to reduce crashes in multi-user environments. Service packs like SP6a further improved overall system robustness, making NT 4.0 a stable platform for server deployments where services handled critical tasks without frequent failures. Windows 2000, launched in 2000, advanced service management by introducing delayed automatic startup, allowing non-critical services to start after initial boot to improve performance, while dependencies on prerequisite services were already managed via registry entries under the SCM to ensure orderly initialization in complex environments like domains. With in 2007, session 0 isolation was implemented to enhance security and stability, reserving session 0 exclusively for system services and processes while reassigning user sessions to higher numbers, thereby preventing service crashes from impacting interactive desktops or enabling shatter attacks. Interactive services, which previously allowed direct interactions from session 0, were deprecated due to security risks, with developers directed to use mechanisms like WTSSendMessage for user notifications via a task host instead. Windows XP Service Pack 2 in 2004 introduced service hardening by running services under limited user accounts to reduce risks. in 2009 added service trigger-start, enabling services to start in response to system events rather than at boot. , released in 2012, introduced new service APIs such as QueryServiceDynamicInformation for retrieving runtime status and expanded trigger support in SERVICE_TRIGGER_SPECIFIC_DATA_ITEM for event-based starts, facilitating integration with modern application models including background tasks for (UWP) apps. In , virtualization-based security (VBS) further evolved service protections by leveraging the to isolate critical components, including services, from through features like memory integrity (Hypervisor-protected Code Integrity), reducing the in protected processes. Starting with updates to and 11 in 2022, services have integrated with the (WSL) via native support, allowing Linux services to run seamlessly under WSL 2 as PID 1 processes, enabling hybrid workloads with tools like and microk8s managed through systemctl commands. Additionally, Arc provides hybrid management for Windows services across on-premises and cloud environments, using the Connected Machine agent to enable centralized updates via Azure Update Manager, monitoring with Monitor, and policy enforcement for fleets of servers.

Architecture

Service Control Manager

The Service Control Manager (SCM) is the central system component in Windows responsible for overseeing the registration, startup, and management of services and device drivers, operating as the user-mode process services.exe launched early during system boot by wininit.exe. It maintains a database of installed services stored in the registry under HKLM\SYSTEM\CurrentControlSet\Services, providing a secure interface for controlling their operation across the system. As a broker, the SCM facilitates service registration by applications or installers, initiates startup sequences in the appropriate order, and enables inter-service communication through its role in coordinating requests and responses. Key functions of the SCM include enumerating all installed services and drivers via APIs like EnumServicesStatus, handling control requests such as starting, stopping, pausing, or resuming through functions like StartService and ControlService, enforcing service dependencies to ensure required launch before dependents, and continuously tracking the of active to report states like running or stopped. It also supports locking and unlocking the database to prevent concurrent modifications during operations like or changes. Internally, the SCM operates as a (RPC) server, using RPC interfaces—often transported over named pipes for local communication—to receive and process requests from clients, including other services or applications. When starting a service, it loads the service executable into either a shared host like for multiple lightweight services or a dedicated for isolated execution, depending on the service's configuration. For error handling, the SCM imposes a default 30-second timeout on service startup attempts; if a service fails to signal readiness within this period, the SCM logs an error event (such as Event ID 7000 or 7011) and may terminate the attempt or apply recovery actions defined in the service's configuration. The SCM's architecture has evolved since to a fully standalone in modern Windows implementations starting with , enhancing modularity and security by isolating service management from other subsystems. This separation allows the SCM to focus exclusively on service orchestration while leveraging kernel-mode drivers for lower-level interactions.

Hosting and Isolation

Windows services are hosted in either shared or dedicated processes to optimize resource usage and performance. Lightweight services, typically implemented as dynamic-link libraries (DLLs), are loaded dynamically into shared processes managed by , which acts as a generic host for multiple services to reduce overhead from multiple executable instances. This shared model groups services with similar security contexts, such as those running under Local Service or accounts, into individual instances configured via registry entries under HKLM\SOFTWARE[Microsoft](/page/Microsoft)\Windows NT\CurrentVersion\SvcHost. In contrast, more complex or resource-intensive services, such as the SQL Server Database Engine (running as sqlservr.exe), operate in dedicated processes to allow independent execution, scaling, and from other services without shared dependencies. Isolation mechanisms ensure services operate securely without interfering with interactive user sessions. Since , services execute exclusively in Session 0, a non-interactive environment reserved for system processes and services, preventing direct access to user desktops and mitigating risks like shatter attacks where malicious code exploits window messages to escalate privileges. This Session 0 isolation integrates with the Terminal Services architecture, where user logons occur in sessions starting from 1, enforcing separation to block services from injecting into or interacting with user-mode applications. Enhanced service host grouping, refined in and later (post-2012), further isolates services by dynamically assigning them to instances based on shared parameters, improving and by containing failures within specific groups. Resource management for hosted services addresses potential conflicts and overuse. To avoid DLL hell—where incompatible DLL versions cause system instability—Windows employs side-by-side (SxS) assemblies, enabling multiple versions of DLLs to coexist in isolated directories, with activation contexts ensuring services load the appropriate version without affecting others. Services, operating in user mode, interact with the kernel through standard APIs but remain confined to user space for stability. They can request the loading of kernel-mode drivers via the Service Control Manager, such as for hardware access, but all service logic executes in user mode to limit crash impacts to the hosting process rather than the entire system.

Service Lifecycle

States and Transitions

Windows services operate through a defined set of states that reflect their operational status, managed by the (SCM). These states include SERVICE_STOPPED, which is the default initial state for all services before any startup attempt; SERVICE_START_PENDING, indicating the service is initializing; SERVICE_RUNNING, the active operational state; SERVICE_STOP_PENDING, signaling shutdown in progress; SERVICE_PAUSE_PENDING, for services supporting pause functionality during the transition to a paused state; SERVICE_PAUSED, a suspended but responsive state; and SERVICE_CONTINUE_PENDING, the transition back from paused to running. State transitions are initiated by requests from the SCM and must follow specific valid sequences to ensure orderly operation. For instance, a typically progresses from SERVICE_STOPPED to SERVICE_START_PENDING upon receiving a start request via the SERVICE_START control code, then to SERVICE_RUNNING once initialization completes and the service reports readiness using the SetServiceStatus function. Similarly, stopping a running involves transitioning to SERVICE_STOP_PENDING in response to a SERVICE_CONTROL_STOP request, followed by SERVICE_STOPPED upon completion. Pause and continue operations follow analogous patterns for supported services, with transitions to SERVICE_PAUSE_PENDING or SERVICE_CONTINUE_PENDING before reaching SERVICE_PAUSED or SERVICE_RUNNING, respectively. Invalid transitions, such as attempting to pause a stopped service, do not trigger errors in API calls but indicate potential implementation issues. Pending states incorporate timeouts to prevent indefinite hangs, with the SCM enforcing a 30-second limit for operations like starting or stopping a ; exceeding this results in a timeout error (e.g., Event ID 7000 or 7011 in the system log) and automatic reversion to SERVICE_STOPPED. Services can extend this by reporting intermediate checkpoints via SetServiceStatus with a wait hint, allowing up to the configured timeout, but prolonged operations require secondary threads to avoid blocking the handler. Services report state changes and handle control requests through a registered control handler function, either Handler or the extended HandlerEx, invoked by the SCM for events like SERVICE_CONTROL_STOP or SERVICE_CONTROL_INTERROGATE. In the handler, the service updates its status using SetServiceStatus to notify the SCM of transitions, such as setting SERVICE_STOP_PENDING during shutdown processing; failure to respond within 30 seconds in the handler leads to SCM intervention. On errors, such as initialization failures in ServiceMain, the service reports an error code via SetServiceStatus and transitions back to SERVICE_STOPPED, ensuring the SCM can manage dependencies and system stability. Real-time monitoring of service states is achieved through SCM APIs like QueryServiceStatus or QueryServiceStatusEx, which retrieve the latest SERVICE_STATUS structure reported by the service, enabling applications to poll for changes without direct intervention. During system shutdown, the SCM issues SERVICE_CONTROL_PRESHUTDOWN (if accepted by the service via SERVICE_ACCEPT_PRESHUTDOWN, with a default timeout of 10 seconds since ) followed by SERVICE_CONTROL_SHUTDOWN requests, forcing transitions to SERVICE_STOP_PENDING with a timeout controlled by the WaitToKillServiceTimeout registry key (default 20 seconds), after which unresponsive services are terminated; services can use wait hints in SetServiceStatus to report progress and extend the effective wait time to complete the shutdown process.

Control Operations

Windows services support a range of control operations managed by the (SCM), enabling runtime management of service behavior through calls that require specific access rights on the service handle. The primary operations include starting a service using the StartService function, which initiates the service's entry point and accepts optional arguments for parametrized starts to customize initialization. Stopping a service is achieved via the SERVICE_CONTROL_STOP code sent through ControlService, requiring SERVICE_STOP access rights and prompting the service to transition to a stopped state. Pausing and continuing operations use SERVICE_CONTROL_PAUSE and SERVICE_CONTROL_CONTINUE codes, respectively, both necessitating SERVICE_PAUSE_CONTINUE access to temporarily suspend or resume non-critical activities without full termination. Querying the service status, a mandatory capability for all services, is handled via SERVICE_CONTROL_INTERROGATE or dedicated QueryServiceStatus functions to retrieve current state details without altering behavior. Advanced control operations extend these basics for specialized scenarios. The SERVICE_CONTROL_SHUTDOWN code notifies services of shutdown, allowing up to 20 seconds for cleanup by via the WaitToKillServiceTimeout registry , which can be configured to a higher value, and requires appropriate rights. Interrogation for custom data uses SERVICE_CONTROL_INTERROGATE to request service-specific information, while parametrized starts via StartService pass command-line arguments directly to the service's ServiceMain for dynamic . User-defined controls in the 128–255 enable operations, requiring SERVICE_USER_DEFINED_CONTROL and integration with the service's control handler. These operations trigger state transitions as defined in the service lifecycle, such as from running to paused or stopped. Service control relies on dedicated handlers for proper response. The ServiceMain function serves as the primary , invoked by the SCM upon start requests to perform initialization and register the control handler using RegisterServiceCtrlHandler or its extended variant. This handler function processes incoming control codes from the SCM, such as stop or pause requests, and must respond within 30 seconds to avoid timeouts. Failure to handle controls appropriately can lead to service instability or forced termination by the SCM. Common error codes provide feedback on operation outcomes. For instance, ERROR_SERVICE_SPECIFIC_ERROR (1066) is returned when a service encounters a custom failure, with details in the service-specific exit code field of the SERVICE_STATUS structure. Other frequent errors include ERROR_ACCESS_DENIED for insufficient rights, ERROR_SERVICE_NOT_ACTIVE if the service is not running, and ERROR_SERVICE_REQUEST_TIMEOUT if processing exceeds the 30-second limit. These codes, retrieved via GetLastError, aid in diagnosing issues during control invocations.

Configuration

Registry Entries

Windows services are configured primarily through registry entries stored under the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<ServiceName>, where <ServiceName> corresponds to the unique name of the service. This key contains essential values that define the service's behavior, executable path, and metadata. For instance, the ImagePath value (REG_SZ) specifies the full path to the service's executable file, such as C:\Windows\System32\svchost.exe -k netsvcs. The DisplayName value (REG_SZ) provides a user-friendly name for the service, like "Windows Update," while the Description value (REG_SZ) offers a brief explanation of its purpose, such as "Enables the detection, download, and installation of updates for Windows and other programs." Key numeric values under this registry key control startup and operational parameters. The Start value (REG_DWORD) determines the startup type: 0 for boot-start (loaded by the boot loader), 1 for system-start (loaded at kernel initialization), 2 for automatic (started by the during boot), 3 for manual (started on demand), and 4 for disabled (prevented from starting). The Type value (REG_DWORD) specifies the service type as a bitmask, including 1 for kernel driver, 2 for driver, 16 for Win32 own process, 32 for Win32 shared process, and 256 for interactive process (deprecated since ). The ErrorControl value (REG_DWORD) defines the system's response to startup failures: 0 to ignore the error and continue, 1 for normal handling (logging the error and possibly displaying a message box) with startup continuing, 2 to log the error and restart using the last-known-good configuration, or 3 to log the error, attempt the last-known-good configuration, and halt startup if that fails as well. Additional values manage dependencies and security. The DependOnService value (REG_MULTI_SZ) lists the names of other services that must start before this one, ensuring proper ordering during boot; for example, it might include "RPCSS" for services relying on remote procedure calls. The RequiredPrivileges value (REG_MULTI_SZ) enumerates the specific user privileges needed by the service, such as "SeDebugPrivilege" for debugging access, stored as a null-terminated multi-string . To support system reliability, Windows maintains multiple versions of the services registry tree under HKEY_LOCAL_MACHINE\SYSTEM, including ControlSet001 and ControlSet002, which serve as backups of the configuration from previous boots. The CurrentControlSet key points to the active (typically ControlSet001), while the LastKnownGood references ControlSet002 during from boot failures, allowing of configurations without .

Dependencies and Startup Types

Windows services can declare dependencies on other services or service groups, which the Service Control Manager (SCM) enforces during startup to ensure required components are available before attempting to start the dependent service. Dependencies form linear chains where the SCM resolves the order by first starting prerequisite services; for instance, the Print Spooler service depends on the (RPC) service, creating a chain that may indirectly rely on underlying network components like the TCP/IP Protocol Driver. The SCM prevents circular dependencies—where two or more services mutually depend on each other—by rejecting configurations that would create such cycles, avoiding potential deadlocks during the boot process. If a dependency fails to start, the SCM propagates the failure, halting the dependent service and potentially triggering system recovery actions based on the error control settings. Service startup types determine when and how the SCM initiates a service, balancing system performance with functionality needs. The primary types include:
  • Boot: Loaded by the boot loader for essential device drivers, starting before the kernel fully initializes.
  • System: Started during kernel initialization for core system drivers.
  • Automatic: Starts immediately at boot, with the SCM also launching any dependent manual services as needed; this ensures critical functionality like networking is available early.
  • Automatic (Delayed Start): Similar to Automatic but postponed until after the boot process completes and other automatic services have loaded, reducing initial boot time by deferring non-essential services—effective only after a system restart.
  • Manual: Starts only upon explicit request, such as via API calls or administrative tools, promoting resource efficiency by keeping idle services dormant.
  • Manual (Trigger Start): A variant of Manual that automatically starts the service in response to specific events, such as network availability, device insertion, or custom Event Tracing for Windows (ETW) events; this can also integrate with Windows Management Instrumentation (WMI) for event-based activation without constant monitoring.
  • Disabled: Prevents the service from starting in any scenario, useful for security hardening or disabling unused components.
These configurations significantly impact system behavior; for example, setting non-critical services like the Print Spooler to (Trigger Start) conserves resources by launching it only on print jobs, while Delayed for background tasks shortens boot times by avoiding contention during early startup phases. To maintain reliable startups, configurations should minimize deep chains, as extensive trees can prolong boot sequences or amplify failure risks if an early link in the chain encounters issues, with the SCM handling propagation through error controls like logging or recovery boots.

Installation

Native Installation

Native installation of Windows services utilizes built-in and command-line tools provided by the operating system, allowing administrators and applications to register services directly with the (SCM) without external dependencies. The primary API for creating a service is the CreateService function, exported from advapi32.dll and declared in winsvc.h. This function requires a to the SCM obtained via OpenSCManager, and the calling process must possess the SC_MANAGER_ALL_ACCESS privilege to successfully create the service entry. To install a service programmatically, the process begins by calling OpenSCManager to connect to the SCM database, typically specifying NULL for the local computer and SERVICES_ACTIVE_DATABASE for the database, along with SC_MANAGER_ALL_ACCESS for full rights. With the resulting SCM handle, CreateService is invoked to add the service object, providing parameters such as the service name (lpServiceName), display name (lpDisplayName), desired access rights (e.g., SERVICE_ALL_ACCESS), the executable's binary path (lpBinaryPathName), startup type (dwStartType, such as SERVICE_AUTO_START for automatic boot initiation), error control behavior (dwErrorControl), and optional dependencies or account details. If immediate startup is required, StartService can follow using the service handle returned by CreateService, which demands SERVICE_START access. This process results in registry entries under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services for the service configuration. For command-line installation, the sc.exe utility—distributed with Windows—offers a straightforward alternative via its create subcommand, which interacts with the SCM to perform the same registration. An example usage is sc create "MyService" binPath= "C:\path\to\service.exe" start= auto, where binPath= specifies the executable path (including arguments if needed), and start= sets the startup type (e.g., auto, demand, or disabled). This command requires administrative privileges and mirrors the API's effect by creating the service database entry and associated registry keys. For Windows services developed using the .NET Framework, the InstallUtil.exe utility, included with the .NET Framework, provides a command-line method to install and uninstall . It executes the installer classes embedded in the to the with the SCM. To install, run InstallUtil.exe path\to\[service](/page/Service).exe from an elevated command prompt (e.g., from C:\Windows\[Microsoft](/page/Microsoft).NET\Framework\v4.0.30319\), specifying the service executable path; use /u flag for uninstallation (e.g., InstallUtil.exe /u path\to\[service](/page/Service).exe). Administrative privileges are required, and the utility handles parameters like startup type via the assembly's installer configuration. Uninstallation via native methods involves the DeleteService or the sc delete command, both of which mark the service for removal from the SCM database rather than immediately deleting it. The DeleteService function uses a service handle obtained from OpenService (requiring DELETE access) and succeeds only if the service is stopped; otherwise, open handles or running state prevent deletion until resolved, with the entry fully removed upon SCM restart or system reboot if necessary. Similarly, sc delete "ServiceName" marks the service subkey for deletion from the registry and SCM, but the service must first be stopped using sc stop to avoid errors, ensuring no active processes hold references.

Third-Party Packaging

Third-party packaging for involves using external utilities and formats to bundle and deploy service executables, simplifying for non-native applications without requiring direct calls. These approaches are particularly useful for legacy software or scripts that lack built-in support, allowing administrators to wrap them into . One widely used tool is the Non-Sucking Service Manager (NSSM), a free utility that wraps any executable as a Windows by configuring parameters such as startup type, dependencies, and restart behavior through a graphical interface or command line. NSSM monitors the wrapped application and restarts it on failure, addressing limitations in older wrappers by providing robust logging and I/O redirection. Another common tool is srvany.exe, part of the Resource Kit, which enables non-service applications to run under the by registering them as services and handling control requests via registry entries. srvany.exe remains available for legacy and is often paired with instsrv.exe for . Packaging formats extend these tools by integrating service installation into broader deployment mechanisms. Microsoft Installer (MSI) packages can include custom actions that invoke the CreateService API to register services during setup, ensuring atomic installation alongside dependencies like files and registry keys. For automated environments, supports service deployment through its Install-ChocolateyWindowsService function, which leverages .NET's InstallUtil.exe for .NET-based services or custom scripts for others, facilitating version-controlled updates across machines. Similarly, , Microsoft's command-line , enables service-inclusive packages by executing post-install scripts that configure services, though it primarily handles application binaries and requires additional scripting for full service lifecycle management. These methods offer advantages in managing dependencies and versioning, as packages can bundle required libraries, configurations, and updates into a single artifact for consistent deployment. For instance, applications can be packaged as services using NSSM by specifying the node.exe path and script arguments, allowing automatic startup and recovery without manual intervention. In Python environments, the pywin32 library provides extensions for service creation, where scripts are compiled into executables and installed via or , handling interactions like service state transitions. Such packaging reduces administrative overhead in enterprise settings by enabling scripted rollouts that include dependency resolution, such as installing runtime environments alongside the service. However, third-party packaging introduces limitations, including potential security risks from wrappers that may expose elevated privileges to untrusted executables if not configured properly. Incomplete uninstallation can also leave orphaned services or registry entries, necessitating manual cleanup to avoid resource leaks or conflicts. Additionally, compatibility issues arise with newer Windows features, like AppContainers, which may restrict wrapper functionality without adjustments.

Administration

Graphical Interfaces

The Services snap-in, invoked by entering services.msc in the Run dialog (opened via Windows + R), serves as the primary graphical console for managing Windows services through the (MMC). It displays a comprehensive list of installed services, enabling users to browse them alphabetically or by status, and supports right-click actions to start, stop, pause, or resume individual services. Additionally, selecting Properties for a service reveals configurable details, including the startup type (e.g., Automatic, Manual, or Disabled), dependencies on other services or groups, and the logon account under which the service operates, such as the Local System account or a specified user. This interface facilitates interactive administration without requiring command-line input, though changes to startup types or logon settings may necessitate a system restart for full effect. Task Manager provides a simpler, integrated graphical view of services via its Services tab, accessible by right-clicking the and selecting , then navigating to the tab. This tab lists all services with columns for name, PID (process ID), status (e.g., Running or Stopped), and group, mirroring the format of the Services console for quick reference. Users can right-click a service to start or stop it, or select Go to Services to open the full Services snap-in for advanced properties. While suitable for basic monitoring and control during , it lacks detailed options like dependency editing. For environments, Server Manager offers role-specific service oversight within its centralized dashboard, particularly useful for multi-server administration. The Local Server page includes a Services tile that aggregates status data for all services on the managed server, while role home pages—such as those for and Services or —display tailored service information relevant to installed roles, allowing filtering by specific servers. An Events tile on these pages links directly to , enabling seamless review of service-related logs filtered by role or server for diagnostics. This integration supports proactive monitoring without leaving the console, though it focuses on overview rather than granular edits. Windows Admin Center (WAC), a browser-based solution available as of 2025, provides modern graphical s for managing services on Windows Servers, including remote connections to multiple servers. It offers a Services for viewing, starting, stopping, and configuring services, with integration for Arc-enabled servers and support for scripting extensions. WAC is particularly suited for hybrid environments and replaces or supplements older tools like Server Manager for comprehensive administration. These graphical tools share limitations inherent to their visual design: they do not support or scripting for batch operations, and all functions—such as starting, stopping, or configuring services—require privileges by default to prevent unauthorized changes.

Command-Line Management

Command-line of Windows services provides a programmatic for querying, starting, stopping, configuring, and monitoring services, enabling in scripts and . These tools interact with the (SCM) to perform operations without requiring graphical interfaces, making them suitable for and integration into larger workflows. The primary utility for comprehensive service management is SC.exe, a command-line tool included in Windows that allows detailed control over and drivers. It supports operations such as querying service status with sc query <servicename>, which displays the current state (e.g., RUNNING, STOPPED), process ID, and binary . Starting a service uses sc start <servicename> [<arguments>], while stopping it employs sc stop <servicename>, both of which send control requests to the SCM and wait for completion. Configuration changes, like modifying startup type or dependencies, are handled via sc config <servicename> <option>=<value>, such as sc config myservice start= delayed-auto to set delayed automatic startup. Additionally, SC.exe manages failure recovery with sc failure <servicename> reset=<seconds> actions=<action1/action2>, for example, sc failure myservice reset=86400 actions=restart/run/[reboot](/page/Reboot) to restart the service on first failure, run a command on second, and on third after 24 hours of error-free operation. These commands require administrative privileges and can target remote machines by specifying \\<servername> as the first parameter. For simpler tasks, NET.exe offers legacy commands focused on basic start and stop operations, often used in older batch files for their brevity. The net start <servicename> command initiates a service, and net stop <servicename> halts it, providing output on success or failure but lacking advanced querying or configuration options. These commands are limited to local or specified remote computers and do not support detailed status retrieval, making them less versatile than SC.exe for modern automation. WMIC (Windows Management Instrumentation Command-line) provides WMI-based service management through queries and method calls, such as wmic service where name="<servicename>" call startservice to start a service or wmic service where name="<servicename>" call stopservice to stop it. It supports filtering and listing services with wmic service list brief for bulk overviews, including names, states, and paths. WMIC was deprecated starting in Windows 10 version 21H1 and has been removed in Windows 11 version 25H2 and later (as of 2025); it is available as an optional Feature on Demand in Windows Server 2025. Microsoft recommends PowerShell or CIM cmdlets for new scripts. PowerShell offers robust, modern command-line management of services via the Microsoft.PowerShell.Management module, suitable for automation and remote operations as the recommended for WMIC. cmdlets include Get-Service to services and their (e.g., Get-Service -Name <servicename> or Get-Service | Where-Object Status -eq 'Stopped' for filtering), Start-Service and Stop-Service to control running state (e.g., Start-Service -Name <servicename>), Set-Service to configure startup type or credentials (e.g., Set-Service -Name <servicename> -StartupType Automatic), and Restart-Service for restarting. These support operations for batch tasks, such as Get-Service | Where-Object Status -eq 'Stopped' | Start-Service, and can target remote computers with -ComputerName. requires administrative privileges and is included by default in Windows. Batch scripting enhances these tools by combining commands in .bat files for bulk operations, such as looping through services with for /f to query and restart multiple instances if stopped. For example, a script might use sc query in a loop to check states and invoke sc start selectively, facilitating automated maintenance tasks like nightly service restarts across servers. Such scripts must be run with elevated privileges and can incorporate handling with conditional statements to log outcomes.

Development

Native Service Creation

Native service creation involves developing Windows services from scratch using native C or C++ code, leveraging the to interact with the (SCM). This process requires implementing specific entry points and following a structured to ensure the service initializes, runs, and responds to controls properly. Services are typically built by linking against the advapi32.lib library, which provides the necessary functions for service management. The main for a executable is the standard main or WinMain function, where the application calls StartServiceCtrlDispatcher to connect to the SCM. This function takes a table of SERVICE_TABLE_ENTRY structures, each specifying the service name and a pointer to its ServiceMain function; the table ends with a entry. Upon success, StartServiceCtrlDispatcher dispatches control to ServiceMain in a new , blocking until the service stops, and returns zero on failure, with errors retrievable via GetLastError. For multi-service executables, the table can include multiple entries. Within ServiceMain, which receives the argument count and vectors via dwArgc and lpszArgv; the first element of lpszArgv is the service name, followed by any additional arguments, the first step is to register a control handler by calling RegisterServiceCtrlHandlerEx. This function takes the service name, a pointer to the HandlerEx callback, and optional context data, returning a SERVICE_STATUS_HANDLE for status updates; it fails if the service name is invalid, with GetLastError providing details like ERROR_SERVICE_NOT_IN_EXE. The HandlerEx prototype is VOID WINAPI HandlerEx(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext), where dwControl includes codes like SERVICE_CONTROL_STOP. Following registration, call ReportServiceStatus (via SetServiceStatus using the handle) to set the initial status, such as SERVICE_START_PENDING, before performing initialization. After initialization, update the status to SERVICE_RUNNING and enter the service's main loop, often using WaitForSingleObject on a stop handle created with CreateEvent to block until signaled. In the loop, the service performs its core operations, periodically calling ReportServiceStatus to update check-point values during pending states or confirm running . For handling, the registered HandlerEx processes requests asynchronously; for SERVICE_CONTROL_STOP, it signals the stop , sets the to SERVICE_STOP_PENDING with a check-point, and returns NO_ERROR without blocking. Other controls, such as interrogate, may require immediate reports but typically do not alter the running state. Upon stop signal reception, the loop exits, cleanup occurs, and the final SERVICE_STOPPED is reported before ServiceMain returns, triggering process termination if no other services run. Error handling throughout involves checking return values and using GetLastError for diagnostics, such as verifying creation succeeds or handler registration yields a valid . Best practices emphasize graceful shutdown by limiting stop-pending time (default 20-30 seconds, configurable via registry) and avoiding long-blocking operations in HandlerEx. For , integrate the Event Log API by opening a log with RegisterEventSource, then calling ReportEvent to write entries with event types (e.g., EVENTLOG_INFORMATION_TYPE), categories, and insertion strings; this requires pre-registering the as an event source in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog. Deregister with DeregisterEventSource on cleanup. These steps ensure robust, SCM-compliant services that handle controls like stop operations as detailed in administration contexts.

Application Wrapping Techniques

Application wrapping techniques enable the conversion of existing console or standalone applications into Windows services without requiring a complete rewrite of the application's code. These methods involve using specialized tools or custom host services to manage the application's lifecycle, including startup, monitoring, and shutdown, while integrating with the Windows Service Control Manager (SCM). This approach is particularly useful for legacy software or scripts that were not originally designed to run in a service context. One common tool for wrapping applications is Srvany.exe, a utility provided by in its Resource Kit tools. Srvany.exe allows any , such as a , to run as a by configuring specific registry entries under the service's key, such as specifying the ImagePath to point to Srvany.exe and adding parameters like Application and AppParameters to launch the target program. Installation typically involves using Instsrv.exe to create the service entry, followed by registry modifications to link the wrapped application. However, Srvany.exe has limitations, including the inability to gracefully stop the wrapped process, as it does not forward service control requests like stop signals to the child application. Commercial alternatives like AlwaysUp and FireDaemon provide more robust wrapping capabilities. AlwaysUp, developed by Core Technologies, installs any executable, batch file, or script as a Windows service, offering features such as automatic restarts on failure, monitoring, and logging to ensure reliability. Similarly, FireDaemon Pro from FireDaemon LLC supports running applications as services with advanced scheduling, crash recovery, and resource , making it suitable for production environments. These tools abstract the complexities of management, allowing administrators to configure the wrapped application through user-friendly interfaces. Beyond pre-built tools, custom wrapping techniques can be implemented by developing a host service that spawns the target application using the CreateProcessAsUser API. This function creates the under a specified user token, enabling the service to launch the application in an appropriate security context, such as the Local System account or a custom user. To manage input and output, the host service redirects the child's stdin, stdout, and stderr to named pipes, allowing the service to capture logs or send commands without a visible console. For graceful shutdown, the host handles SERVICE_CONTROL_STOP requests from the SCM and forwards them to the using GenerateConsoleCtrlEvent to simulate a CTRL_C_EVENT, giving the application an opportunity to clean up resources before termination. Specific examples illustrate these techniques in practice. For applications, the Java Service Wrapper from Tanuki Software acts as a native that launches the JVM as a service, handling JVM crashes and system signals while providing configuration options for startup parameters and logging. In the .NET ecosystem, the TopShelf library allows developers to transform a console application into a self-installing service by adding a few lines of code to configure hosting behaviors, such as service name and recovery actions, without altering the core application logic. Despite their utility, application wrapping techniques introduce potential drawbacks, including instability if the does not respond correctly to lifecycle events, leading to hangs during stops or restarts. Debugging wrapped applications can be challenging, as errors may not propagate clearly to event logs, and console output requires explicit redirection. These methods are not ideal for high-reliability production scenarios without thorough testing to ensure compatibility with controls.

Security

Account and Privilege Management

Windows services operate under specific accounts that determine their level of access to system resources. The serves as the default for many services, providing complete, unrestricted access to local resources as it impersonates the computer itself on the network. In contrast, the offers minimum privileges on the local computer, presenting anonymous credentials to other systems, while the similarly limits local access but authenticates as the computer account on the network. Services can also be configured to run under custom user accounts, including domain accounts, to enforce more granular security boundaries. Account configuration for services is managed through the Services console (services.msc), where the Log On tab allows selection of built-in accounts like LocalSystem or specification of a custom user account with its password. For command-line operations, the Service Control (sc) tool uses the sc config command with the obj= parameter to set the logon account, such as for domain accounts, followed by the password= parameter if needed. These settings ensure services authenticate appropriately without manual intervention for password changes in managed scenarios. Privileges for services are inherited from their assigned accounts and can include advanced rights like SeDebugPrivilege, which enables debugging and adjustment of processes owned by other accounts, or SeBackupPrivilege, which grants read to any file for backup operations regardless of ACLs. To query or manage these privileges, applications use the OpenService function with the SC_MANAGER_ALL_ACCESS right, allowing full control over service security descriptors. LocalSystem inherently possesses all privileges, while limited accounts like LocalService and NetworkService have restricted sets to minimize exposure. Running services under LocalSystem introduces significant risks, as vulnerabilities in the service can lead to system-wide compromise; for instance, exploits like CVE-2013-1337 in allowed elevation to LocalSystem privileges. To mitigate these, administrators are encouraged to migrate to least-privilege accounts, with Group Managed Service Accounts (gMSAs) introduced in providing automated password management and shared identities across multiple servers without exposing credentials. Delegated Managed Service Accounts (dMSAs), introduced in Windows Server 2025, offer managed credentials for standalone servers without requiring an domain, enhancing security in non-domain environments.

Hardening and Isolation Features

Windows services incorporate several built-in hardening and isolation mechanisms to mitigate exploits, prevent unauthorized code execution, and limit the of running processes. These features leverage process protection, , and token restrictions to ensure that services operate in constrained environments, reducing the risk of or by malicious actors. Critical services, such as those involved in security operations, benefit from enhanced protections that isolate them from untrusted components. Protected Process Light () provides a lightweight protection model for user-mode services, particularly anti-malware services, by restricting code loading and preventing non-protected processes from injecting or writing to the service's . Introduced in , PPL requires service binaries to be signed with valid certificates and integrates with Early Launch Anti-Malware () drivers to enforce during boot. Services can be configured for PPL using the ChangeServiceConfig2 with the SERVICE_CONFIG_LAUNCH_PROTECTED_ANTIMALWARE_LIGHT flag, allowing child processes to inherit the same protection level and thereby safeguarding against tampering attempts. Virtualization-Based Security (VBS), available since , utilizes to create isolated regions in memory, protecting sensitive services from kernel-mode attacks through features like Credential Guard and Device Guard. A key component, Hypervisor-Protected Code Integrity (HVCI)—also known as memory integrity—enforces stricter and execution policies by running kernel-mode code integrity checks in an isolated environment, preventing unsigned or malicious drivers from loading into services. In , HVCI enhancements support zero-trust isolation by default on compatible , extending protections to more system services and improving runtime integrity verification without requiring manual configuration. AppContainers offer sandboxing for services by confining them to isolated execution environments that restrict access to system resources, files, networks, and other processes, thereby containing potential breaches. While primarily designed for applications, services can launch or host processes within AppContainers using APIs like CreateAppContainerProfile, which enforces capability-based access controls and prevents inter-process interference. This isolation mechanism, built on the Windows kernel's security model, ensures that compromised services cannot escalate to affect the broader system. Service binary signing is a mandatory requirement for protected services under features like PPL and HVCI, where executables must be digitally signed with Authenticode or EV certificates to verify authenticity and integrity before loading. Unsigned or tampered binaries are blocked from execution, reducing the risk of supply-chain attacks; administrators can enforce this via or code integrity policies to apply uniformly across services. Run-level isolation utilizes Mandatory (MIC) to assign services integrity levels such as medium or low, limiting their ability to interact with higher-integrity resources like system files or the registry. Services typically operate at high or system integrity by default, but can be configured to lower levels during creation or via token adjustments, preventing unauthorized modifications and enforcing least-privilege execution. This aligns with broader account privileges by restricting service tokens to non-elevated contexts where possible. Exploit mitigations like (ASLR) and Data Execution Prevention (DEP) are enforced system-wide for services to randomize memory layouts and prohibit code execution in non-executable regions, respectively. These can be strengthened per-service using Process Mitigation Policies, ensuring that even if a vulnerability is exploited, attackers face additional barriers to control flow hijacking. The CreateRestrictedToken API further enhances isolation by generating tokens with disabled privileges, reduced SIDs, or deny-only entries, allowing services to spawn child processes with minimal permissions and avoiding full administrative access.

Troubleshooting

Common Failure Modes

Windows services can encounter startup failures due to several common issues. Path errors, such as missing binaries or incorrect paths specified in the , prevent the service from loading its core components and result in errors like 1053, indicating the service did not respond in a timely fashion. Dependency loops occur when services are configured to require each other for startup, creating circular references that halt the initialization entirely. Insufficient privileges, where the lacks necessary permissions to access , registry keys, or resources, also lead to startup denials, particularly in restricted environments like domain controllers. Port conflicts arise when a service attempts to to a already in use by another or service, causing binding failures and preventing network-dependent services from starting. During , services may fail due to unhandled exceptions in their , which terminate abruptly without recovery, often seen in .NET-based services where exceptions like FileNotFoundException propagate unchecked. leaks, where services fail to release allocated over time, gradually increase resource consumption and can lead to crashes under prolonged operation. Resource exhaustion, such as reaching the per-process on open handles (2^24 or 16,777,216 on modern Windows versions), occurs when services accumulate unclosed handles to files, sockets, or registry entries, degrading overall system and forcing service restarts. These failures can have broader system impacts, including boot delays where a hung service startup process exceeds the default 30-second timeout, prolonging the overall sequence. In rare cases, particularly with kernel-mode drivers masquerading as services or faulty user-mode interactions with kernel components, failures may trigger (BSOD) errors like SYSTEM_SERVICE_EXCEPTION, though user-mode services are generally isolated from causing such crashes. To prevent these issues, service installations should include validation checks to verify file paths, dependencies, and privilege requirements before registration, as recommended in Windows Installer best practices. Ongoing monitoring of resource thresholds, such as memory usage and handle counts via performance counters, allows for proactive intervention to avoid exhaustion-related failures.

Diagnostic Tools and Logs

Windows services utilize the Windows Event Log system to record operational events, errors, and informational messages, which can be viewed and analyzed using the Event Viewer tool. The Event Viewer provides access to standard logs such as the Application log for service-specific errors and the System log for events, including starts, stops, and failures. Services can register custom event sources using the RegisterEventSource function, allowing them to write structured events to these logs for targeted diagnostics. For instance, when a service encounters an exception during execution, it can report the details via ReportEvent, ensuring the information is timestamped and categorized by severity levels like error, warning, or information. Several specialized tools aid in tracing service behavior beyond basic event logging. (ProcMon), a utility, captures real-time file system, registry, process, and thread activity, making it valuable for diagnosing issues like access denied errors or dependency failures in services. DebugView, another tool, intercepts debug output from services running in user mode, capturing console-like messages that might otherwise be invisible, which is particularly useful for services configured with debug privileges. enables the collection of service-specific counters, such as CPU utilization, memory allocation, and I/O rates, to identify resource bottlenecks affecting service performance. For advanced troubleshooting, particularly with crashes or hangs, serves as a powerful and user-mode debugger to analyze dumps and stack traces from failed services. The command-line tool sc queryex provides extended status details, including process , flags, and checkpoint information, offering deeper insights than basic queries for services in transitional states. In , the Get-Service cmdlet supports error handling via the -ErrorAction parameter, allowing scripts to suppress or log errors during service status checks without halting execution. Best practices for effective diagnostics include enabling debug output in service code during to facilitate , which can be captured using tools like DebugView before deployment. Correlating across logs by timestamps and service names helps pinpoint causal relationships, such as a dependency failure triggering a cascade of errors. Regularly reviewing these logs and traces ensures proactive issue resolution, minimizing downtime from common service disruptions.

References

  1. [1]
    Introduction to Windows Service Applications - .NET Framework
    Sep 15, 2021 · Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions.Service Applications vs. Other... · Service Lifetime
  2. [2]
    About Services - Win32 apps - Microsoft Learn
    Jan 7, 2021 · The service control manager (SCM) maintains a database of installed services and driver services, and provides a unified and secure means of controlling them.
  3. [3]
    Services (Services) - Win32 apps - Microsoft Learn
    Jan 7, 2021 · This module discusses the role of operating system services and how to troubleshoot issues that restrict functionality. This module also ...
  4. [4]
    Troubleshoot problems on the DHCP client - Windows Server
    Jan 15, 2025 · The DHCP Client service is started and running. To check this, run the net start command, and look for DHCP Client . There is no firewall ...
  5. [5]
    Microsoft Defender Antivirus in Windows Overview
    Oct 20, 2025 · Microsoft Defender Antivirus is built into Windows, and it works with Microsoft Defender for Endpoint to provide protection on your device and in the cloud.Prerequisites · Microsoft Defender Antivirus...
  6. [6]
    Service Changes for Windows Vista - Win32 apps | Microsoft Learn
    Jan 7, 2021 · Session 0 Isolation, Services have always run in session 0. Before Windows Vista, the first user to log on was also assigned to session 0.
  7. [7]
    Interactive Services - Win32 apps | Microsoft Learn
    Jan 7, 2021 · Therefore, if an interactive service displays a user interface, it is visible only to the user who connected to session 0. Because there is no ...
  8. [8]
    Security guidelines for system services in Windows Server 2016
    Aug 22, 2024 · Provides security guidelines and recommendations for disabling services in Windows Server 2016 with Desktop Experience.
  9. [9]
    Overview of Windows as a service - Deployment - Microsoft Learn
    Jun 17, 2025 · Windows as a service is a way to build, deploy, and service Windows. Learn how Windows as a service works.Servicing · Building · Deploying
  10. [10]
    The Systems Internals Newsletter Volume 2, Number 3
    The newly released TCPView Pro allows you to monitor TCP/IP activity on Windows NT 4.0, Windows 2000, and Windows 95/98 systems.
  11. [11]
    Microsoft Releases Service Pack 4.0 for Windows NT Workstation ...
    Oct 19, 1998 · Service Pack 4.0 contains enhancements to the Windows NT operating system including font support for the euro, Microsoft Windows Media ...
  12. [12]
    The Systems Internals Newsletter Volume 4, Number 2
    Aug 12, 2002 · Winternals Software is the leading developer and provider of advanced systems tools for Windows NT/2K/XP. Winternals Software products include ...Psinfo V1. 33 · Internals Information · Inside Windows Nt...<|separator|>
  13. [13]
    Delay Services in Windows 2000/XP/2003 - Petri IT Knowledgebase
    Jan 8, 2009 · To create a new dependency, select the subkey representing the service you want to delay, click Edit, and then click Add Value.
  14. [14]
    Whats New in Services for Windows 8 - Win32 apps | Microsoft Learn
    Jan 7, 2021 · Windows 8 and Windows Server 2012 include the following new capabilities for services ... UWP · Web · Windows IoT · Mixed Reality · Games.
  15. [15]
    Virtualization-based Security (VBS) - Microsoft Learn
    Feb 27, 2025 · Virtualization-based security, or VBS, uses hardware virtualization and the Windows hypervisor to create an isolated virtual environment ...
  16. [16]
    Use systemd to manage Linux services with WSL - Microsoft Learn
    Mar 17, 2025 · Windows Subsystem for Linux (WSL) now supports systemd, an init system and service manager used by many popular Linux distributions such as Ubuntu, Debian, and ...
  17. [17]
    Azure Arc-enabled servers Overview - Microsoft Learn
    Jan 23, 2025 · Azure Arc-enabled servers lets you manage Windows and Linux physical servers and virtual machines hosted outside of Azure, on your corporate network, or other ...Supported cloud operations · Supported regions
  18. [18]
    Service control manager - Win32 apps - Microsoft Learn
    Feb 7, 2022 · This module discusses the role of operating system services and how to troubleshoot issues that restrict functionality. This module also ...
  19. [19]
    [MS-SCMR]: Overview - Microsoft Learn
    Aug 11, 2025 · The Service Control Manager Remote Protocol is a client/server protocol used for configuring and controlling service programs running on a remote computer.
  20. [20]
    A slow service does not start due to time-out error in Windows
    Jan 15, 2025 · This article provides a workaround to an issue where a slow service does not start due to time-out error in Windows.
  21. [21]
    System freeze with Event 7009 - timeout - Microsoft Q&A
    Jul 4, 2010 · The Service Control Manager will generate an event if a service does not respond within the defined timeout period (the default timeout period is 30000 ...
  22. [22]
    Microsoft Security Bulletin MS00-053 - Critical
    The Service Control Manager is an administrative tool provided in Windows 2000 that allows system services to be created or modified. What are named pipes ...Missing: dependency management<|separator|>
  23. [23]
    Service Programs - Win32 apps - Microsoft Learn
    Jan 7, 2021 · An example of a service program that does this is the generic service host process, Svchost.exe, which hosts internal Windows services. Note ...
  24. [24]
    Service host grouping in Windows 10 | Microsoft Learn
    Feb 23, 2023 · The Service Host (svchost.exe) is a shared-service process that serves as a shell for loading services from DLL files.
  25. [25]
    Configure Windows Service Accounts and Permissions - SQL Server
    Each service in SQL Server represents a process or a set of processes to manage authentication of SQL Server operations with Windows.Missing: dedicated | Show results with:dedicated
  26. [26]
    Application Compatibility - Session 0 Isolation
    The Microsoft Windows Vista operating system mitigates this security risk by isolating services in Session 0 and making Session 0 non-interactive. In Windows ...
  27. [27]
    About Side-by-Side Assemblies - Win32 apps - Microsoft Learn
    Jan 7, 2021 · A side-by-side assembly contains a collection of resources—a group of DLLs, Windows classes, COM servers, type libraries, or interfaces—that are ...Missing: services hell
  28. [28]
    Windows System Resource Manager Overview | Microsoft Learn
    Aug 31, 2016 · Windows System Resource Manager only manages processor resources when the combined processor load is greater than 70 percent. This means that it ...
  29. [29]
    User Mode and Kernel Mode - Windows drivers - Microsoft Learn
    Oct 28, 2025 · Core operating system components function in kernel mode. Although many drivers operate in kernel mode, some can function in user mode. User ...
  30. [30]
    Service State Transitions - Win32 apps - Microsoft Learn
    Jan 7, 2021 · A service starts as SERVICE_STOPPED, then transitions to SERVICE_START_PENDING, then SERVICE_RUNNING. Transitions are reported to SCM, and only ...
  31. [31]
    The Windows Trace Session Manager service does not start and ...
    Jan 15, 2025 · This article provides a workaround for an issue where the Windows Trace Session Manager service doesn't start in the specified time.
  32. [32]
    Service Control Handler Function - Win32 apps
    ### Summary of Service Control Handler Function
  33. [33]
    QueryServiceStatus function (winsvc.h) - Win32 apps | Microsoft Learn
    Feb 22, 2024 · The QueryServiceStatus function returns the most recent service status information reported to the service control manager.
  34. [34]
    Starting a Service - Win32 apps - Microsoft Learn
    Jan 7, 2021 · To start a service, a service control program opens a handle to an installed database and then specifies the handle in a call to the StartService function.
  35. [35]
    ControlService function (winsvc.h) - Win32 apps | Microsoft Learn
    Jul 26, 2022 · The ControlService function asks the Service Control Manager (SCM) to send the requested control code to the service.
  36. [36]
    SERVICE_STATUS structure (winsvc.h) - Win32 - Microsoft Learn
    Apr 1, 2021 · Contains status information for a service. The ControlService, EnumDependentServices, EnumServicesStatus, and QueryServiceStatus functions use this structure.
  37. [37]
    HKLM\SYSTEM\CurrentControlSet\Services Registry Tree
    Oct 9, 2024 · The HKLM\SYSTEM\CurrentControlSet\Services registry tree stores information about each service on the system. Each driver has a key of the form HKLM\SYSTEM\ ...
  38. [38]
    Detect, enable, and disable SMBv1, SMBv2, and SMBv3 in Windows
    Mar 11, 2025 · Key path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation. Registry entry: DependOnService; Entry type: REG_MULTI_SZ ...SMBv1 is not installed by default · Overview of file sharing using...
  39. [39]
    SERVICE_REQUIRED_PRIVILE...
    Nov 19, 2024 · The `SERVICE_REQUIRED_PRIVILEGES_INFOW` structure represents required privileges for a service, specified as a multi-string of privileges. ...
  40. [40]
    Automatically Starting Services - Win32 apps - Microsoft Learn
    Apr 10, 2024 · ... registry value: HKEY_LOCAL_MACHINE\System\Select\LastKnownGood. If an auto-start service with a SERVICE_ERROR_CRITICAL error control level ...
  41. [41]
    Guidance on disabling system services on Windows IoT Enterprise
    Jan 12, 2024 · This article includes detailed guidance regarding which services can safely be disabled as well as links to more resources that provide step by step ...
  42. [42]
    [MS-SCMR]: Abstract Data Model - Microsoft Learn
    Apr 27, 2022 · Multiple service names are separated by a null. Direct or indirect circular dependencies on the same service are not allowed. ErrorControl.
  43. [43]
    sc.exe config | Microsoft Learn
    Feb 3, 2023 · Specifies the start type for the service. The options include: boot - Specifies a device driver that is loaded by the boot loader.
  44. [44]
    Service Trigger Events - Win32 apps | Microsoft Learn
    Jan 7, 2021 · A service can register to be started or stopped when a trigger event occurs. This eliminates the need for services to start when the system starts.
  45. [45]
    SERVICE_TRIGGER structure (winsvc.h) - Win32 - Microsoft Learn
    Apr 1, 2021 · The event is a custom event generated by an Event Tracing for Windows (ETW) provider. This trigger event can be used to start or stop a service.
  46. [46]
    Service Installation, Removal, and Enumeration - Win32 apps
    Jan 7, 2021 · A configuration program uses the DeleteService function to remove an installed service from the database. For more information, see Deleting a ...
  47. [47]
    CreateServiceA function (winsvc.h) - Win32 apps - Microsoft Learn
    Jul 26, 2022 · ... key with the same name as the service under the following registry key:HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services. Information ...<|separator|>
  48. [48]
    Service Security and Access Rights - Win32 apps | Microsoft Learn
    Jan 7, 2021 · The Windows security model enables you to control access to the service control manager (SCM) and service objects.
  49. [49]
    OpenSCManagerA function (winsvc.h) - Win32 apps | Microsoft Learn
    Feb 9, 2023 · Establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
  50. [50]
    Installing a Service - Win32 apps - Microsoft Learn
    Sep 20, 2022 · schSCManager = OpenSCManager( NULL, // local computer NULL, // ServicesActive database SC_MANAGER_ALL_ACCESS); // full access rights if ...
  51. [51]
    StartServiceA function (winsvc.h) - Win32 apps - Microsoft Learn
    Feb 8, 2023 · ... QueryServiceStatus function periodically to query the service's status. A service cannot call StartService during initialization. The reason ...Parameters · Return Value · Remarks
  52. [52]
    sc.exe create - Microsoft Learn
    Sep 29, 2023 · Creates a subkey and entries for a service in the registry and in the Service Control Manager database.Sc.exe config · Sc · Sc delete
  53. [53]
    DeleteService function (winsvc.h) - Win32 apps | Microsoft Learn
    Oct 12, 2021 · The DeleteService function marks a service for deletion from the service control manager database. The database entry is not removed until all open handles to ...
  54. [54]
    sc delete - Microsoft Learn
    Aug 15, 2025 · Reference article for the sc delete command, which deletes a service subkey from the registry.
  55. [55]
    NSSM - the Non-Sucking Service Manager
    nssm is a service helper which doesn't suck. srvany and other service helper programs suck because they don't handle failure of the application running as a ...Download · Usage · Command line · Use casesMissing: documentation | Show results with:documentation
  56. [56]
    Create a user-defined service - Windows Client - Microsoft Learn
    Jan 15, 2025 · Describes how to create a Windows NT user-defined service.
  57. [57]
    Create a Windows Service installer - .NET - Microsoft Learn
    Dec 13, 2023 · This tutorial is a continuation of the Create a Windows Service tutorial. It shows how to create an installer for your .NET Windows Service.
  58. [58]
    Install-ChocolateyWindowsService - Chocolatey Software Docs
    This function requires a Chocolatey for Business License to use. Installs a Windows Service using Install Util, plus some extra awesome-sauce.Syntax · Description · Examples · Parameters
  59. [59]
    Use WinGet to install and manage applications | Microsoft Learn
    Sep 15, 2025 · WinGet is a command line tool enabling users to discover, install, upgrade, remove and configure applications on Windows 10, Windows 11, and Windows Server ...Explore the Windows Package... · Winget download command · Install Command
  60. [60]
    Usage - NSSM - the Non-Sucking Service Manager
    You can use nssm to install a service. The command to type is: nssm install <servicename> The installer consists of several tabs with lots of configurable ...Missing: wrapper | Show results with:wrapper
  61. [61]
    pywin32 - PyPI
    pywin32 provides access to many Windows APIs from Python, including COM support. Install it via pip: `python -m pip install --upgrade pywin32`.Pywin32 302 · Pywin32 225 · Pywin32 300 · Types-pywin32
  62. [62]
    Troubleshoot processes by using Task Manager - Windows Server
    Jan 15, 2025 · Task Manager monitors process performance and resource usage. It helps by examining CPU load, process details, and wait chains to troubleshoot.
  63. [63]
    Manage the Local Server and the Server Manager Console
    Jun 8, 2022 · Learn how to manage both the local server and remote servers that are running Windows Server 2008 and newer releases of the Windows Server ...Shut down the local server · Configure Server Manager...
  64. [64]
    Grant users rights to manage services - Windows Server
    Jan 15, 2025 · This article describes methods that you can use to grant the appropriate rights to users to manage services.
  65. [65]
    Controlling a Service Using SC - Win32 apps | Microsoft Learn
    Mar 28, 2023 · The Windows SDK contains a command-line utility, Sc.exe, that can be used to control a service. Its commands correspond to the functions provided by the SCM.
  66. [66]
    Sc.exe query | Microsoft Learn
    Feb 3, 2023 · Reference article for the sc.exe query command, which obtains and displays information about the specified service, driver, type of service, ...
  67. [67]
    Sc failure | Microsoft Learn
    Aug 31, 2016 · To run a batch file when a service fails, specify command= Cmd.exe** **Drive:\FileName.bat, where Drive:\FileName.bat is the fully qualified ...
  68. [68]
    Start, Stop, Pause, Resume, and Restart SQL Server Services
    Aug 26, 2025 · The SQL Server services can be started, stopped, or paused by using Windows net commands. ... To stop a service, replace net start with net stop .
  69. [69]
    WMI command-line (WMIC) utility - Win32 apps | Microsoft Learn
    Jul 15, 2024 · The WMI command-line (WMIC) utility provides a command-line interface for Windows Management Instrumentation (WMI). WMIC is compatible with existing shells and ...
  70. [70]
    StartServiceCtrlDispatcherA function (winsvc.h) - Win32 apps
    ### Summary of StartServiceCtrlDispatcherA Function
  71. [71]
    Writing a ServiceMain Function - Win32 apps | Microsoft Learn
    Jan 7, 2021 · The SvcMain function first calls the RegisterServiceCtrlHandler function to register the SvcCtrlHandler function as the service's Handler ...
  72. [72]
    RegisterServiceCtrlHandlerExA function (winsvc.h) - Win32 apps
    Feb 8, 2023 · The ServiceMain function of a new service should immediately call the RegisterServiceCtrlHandlerEx function to register a control handler function with the ...
  73. [73]
    Writing a Control Handler Function - Win32 apps
    ### Summary of Writing a Control Handler Function
  74. [74]
    The Complete Service Sample - Win32 apps | Microsoft Learn
    Jan 7, 2021 · The following procedure describes how to build the service and register the event message DLL. To build the service and register the event ...
  75. [75]
    ReportEventA function (winbase.h) - Win32 apps | Microsoft Learn
    Feb 8, 2023 · This function is used to log an event. The entry is written to the end of the configured log for the source identified by the hEventLog parameter.
  76. [76]
    Reporting Events - Win32 apps - Microsoft Learn
    Aug 14, 2025 · To report events, define them in a message text file, then use the ReportEvent function to write them. Use Windows Event Log for Vista or later.
  77. [77]
    The Top 3 Real-World Problems with Microsoft Srvany
    Jun 21, 2021 · Microsoft Srvany is designed to run any application/program as a Windows Service. Here are the top 3 problems to watch out for as you use ...
  78. [78]
    Run Any Application as a Windows Service at Boot | AlwaysUp
    Rating 4.9 (11,406) · $49.99 · WindowsAlwaysUp starts your program at boot and runs it 24x7 as a bulletproof Windows Service. · An easy to use Interface to run any Program as a Windows Service · Key ...How AlwaysUp Works · Download AlwaysUp · AlwaysUp Licensing Options... · FAQMissing: wrapper | Show results with:wrapper
  79. [79]
    Run Application Program as a Windows Service | FireDaemon Pro
    FireDaemon Pro allows you to run any program as a Windows service, without login, and restart it automatically if it crashes.FireDaemon Pro 6 Pricing · FireDaemon Pro and Pro OEM... · Download TrialMissing: wrapper | Show results with:wrapper
  80. [80]
    CreateProcessAsUserW function (processthreadsapi.h) - Win32 apps
    Feb 8, 2023 · CreateProcessAsUser allows you to access the specified directory and executable image in the security context of the caller or the target user.
  81. [81]
    Creating a Child Process with Redirected Input and Output
    Jul 14, 2025 · The example in this topic demonstrates how to create a child process using the CreateProcess function from a console process.Missing: service wrapping
  82. [82]
    GenerateConsoleCtrlEvent function - Windows Console
    Aug 26, 2021 · Sends a specified signal to a console process group that shares the console associated with the calling process.Missing: service wrapper stop
  83. [83]
    Java Service Wrapper: Home
    The Java Service Wrapper is a proven enterprise-class solution which drastically simplifies the deployment, launch and monitoring of your Java application.Download · Documentation · Run as Windows Service · Licensing Overview
  84. [84]
    Topshelf/Topshelf: An easy service hosting framework for building ...
    Jul 26, 2022 · Topshelf is a framework for hosting services written using the .NET framework. The creation of services is simplified, allowing developers to create a simple ...
  85. [85]
    LocalSystem Account - Win32 apps - Microsoft Learn
    Jan 7, 2021 · The LocalSystem account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem.
  86. [86]
    LocalService Account - Win32 apps - Microsoft Learn
    Jan 7, 2021 · The LocalService account is a predefined local account used by the service control manager. It has minimum privileges on the local computer and presents ...
  87. [87]
    NetworkService Account - Win32 apps - Microsoft Learn
    Jan 7, 2021 · The NetworkService account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem.Missing: LocalSystem | Show results with:LocalSystem
  88. [88]
    Service Accounts in Windows Server | Microsoft Learn
    Jul 8, 2025 · A service account is a user account that's created explicitly to provide a security context for services that are running on Windows Server operating systems.
  89. [89]
    Privilege Constants (Winnt.h) - Win32 apps | Microsoft Learn
    Apr 7, 2022 · Privilege constants are defined as strings in Winnt.h. For example, the SE_AUDIT_NAME constant is defined as "SeAuditPrivilege".Example · Constants
  90. [90]
    Using the LocalSystem Account as a Service Logon Account
    One advantage of running under the LocalSystem account is that the service has complete unrestricted access to local resources.
  91. [91]
    Microsoft Security Bulletin MS13-034 - Important
    Apr 9, 2013 · An attacker who successfully exploited this vulnerability could execute arbitrary code in the security context of the LocalSystem account and ...
  92. [92]
    Group Managed Service Accounts overview | Microsoft Learn
    Jul 1, 2025 · A group Managed Service Account (gMSA) extends the functionality of a standalone MSA over multiple servers, providing a single identity ...Feature description · Practical applications
  93. [93]
    Protecting anti-malware services - Win32 apps | Microsoft Learn
    Aug 8, 2022 · Learn about protecting anti-malware (AM) user mode services and how you can opt to include this feature in your anti-malware service.Introduction · System-protected process
  94. [94]
    Memory integrity and virtualization-based security - Microsoft Learn
    Memory integrity is a virtualization-based security (VBS) feature that protects Windows from kernel-level malware attacks. Available in Windows 10, Windows ...
  95. [95]
    Windows 11 security book - Silicon assisted security | Microsoft Learn
    Nov 18, 2024 · Hypervisor-protected code integrity (HVCI), also called memory integrity, uses VBS to run Kernel Mode Code Integrity (KMCI) inside the secure ...<|control11|><|separator|>
  96. [96]
    AppContainer isolation - Win32 apps | Microsoft Learn
    Jul 8, 2025 · Sandboxing the application kernel objects, the AppContainer environment prevents the application from influencing, or being influenced by ...
  97. [97]
    Launch an AppContainer - Win32 apps - Microsoft Learn
    Sep 3, 2025 · They provide a sandboxed environment for applications, restricting their ability to access system or each other's resources, as well as user ...Appcontainer Overview · Constructing The... · Launching The Appcontainer...
  98. [98]
    Driver Signing With Digital Signatures - Windows - Microsoft Learn
    Jul 11, 2025 · The process requires an extended validation (EV) certificate. For more information, see Driver signing policy.
  99. [99]
    Mandatory Integrity Control - Win32 apps - Microsoft Learn
    Jul 8, 2025 · Windows defines four integrity levels: low, medium, high, and system. Standard users receive medium, elevated users receive high. Processes you ...Integrity Labels · Process Creation
  100. [100]
    Exploit protection reference - Microsoft Defender for Endpoint
    Mar 25, 2025 · This article helps you understand how exploit protection works, both at the policy level and at the individual mitigation level.
  101. [101]
    Access Tokens - Win32 apps - Microsoft Learn
    Jul 8, 2025 · CreateRestrictedToken, Creates a new token that is a restricted version of an existing token. The restricted token can have disabled SIDs ...Missing: services | Show results with:services
  102. [102]
    Troubleshoot Netlogon Service Startup Failures - Windows Server
    May 15, 2025 · An invalid service might be configured in the DependOnService registry value of the Netlogon service, or the service referenced in this ...
  103. [103]
    Troubleshoot service startup permissions in Windows Server 2003
    Jan 15, 2025 · This article describes how to troubleshoot Service Startup permissions in a Microsoft Windows Server 2003 environment.Missing: common | Show results with:common<|control11|><|separator|>
  104. [104]
    Windows Server 2012 R2 &#8211; Resolving Port Conflict with IIS ...
    Oct 15, 2013 · Port conflicts occur because Work Folders and IIS use the same default ports. Solutions include changing ports, or using separate VMs, or an in ...
  105. [105]
    .NET Runtime The process was terminated due to an unhandled ...
    Nov 28, 2018 · The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException at System.IO.__Error.WinIOError(Int32, System.String)
  106. [106]
    Application or Service Memory Leaks Troubleshooting Guidance
    Aug 12, 2025 · This article provides guidance on troubleshooting applications or services with memory leak behaviors and how to proceed.
  107. [107]
    The handle count of the system process keeps increasing in ...
    The issue occurs because the iSCSI driver (Msiscsi.sys) does not close all registry handles after you query the persistent iSCSI targets information.
  108. [108]
    Windows service fails to start automatically after reboot - Microsoft Q&A
    Oct 7, 2025 · Event ID 7000 and 7009 confirm a startup timeout. The recommended fix is to increase the ServicesPipeTimeout registry value so SCM waits longer ...
  109. [109]
    Blue Screen Of Death (SYSTEM_SERVICE_EXCEPTION) from Task ...
    Dec 19, 2021 · I open the task manager and try to switch the tab from 'processes' to any other tab, eg 'performance', I get a blue screen with the error code SYSTEM_SERVICE_ ...
  110. [110]
    Windows Installer Best Practices - Win32 apps | Microsoft Learn
    Dec 14, 2022 · Concurrent Installations, also called Nested Installations, install another Windows Installer package during a currently running installation.
  111. [111]
    How to: Log Information About Services - .NET Framework
    Apr 30, 2024 · All Windows Service projects have the ability to interact with the Application event log and write information and exceptions to it.
  112. [112]
    RegisterEventSourceA function (winbase.h) - Win32 - Microsoft Learn
    Feb 22, 2024 · The name of the event source whose handle is to be retrieved. The source name must be a subkey of a log under the Eventlog registry key.
  113. [113]
    Process Monitor - Sysinternals | Microsoft Learn
    Jun 20, 2024 · Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity.Introduction · Overview of Process Monitor...
  114. [114]
    DebugView - Sysinternals - Microsoft Learn
    Apr 23, 2019 · DebugView is an application that lets you monitor debug output on your local system, or any computer on the network that you can reach via TCP/IP.Introduction · DebugView Capture
  115. [115]
    Troubleshoot issues using Performance Monitor - Windows Server
    Jan 15, 2025 · Performance Monitor is an MMC snap-in in Windows that helps monitor system usage and various performance metrics.
  116. [116]
    The application or service crashing behavior troubleshooting guidance
    Jan 15, 2025 · This article provides guidance on how to troubleshoot application or service crashing behaviors. Applies to: All supported versions of Windows Server and ...Missing: runtime | Show results with:runtime
  117. [117]
    Configuring a Service Using SC - Win32 apps | Microsoft Learn
    Mar 27, 2023 · The Windows SDK contains a command-line utility, Sc.exe, that can be used to query or modify the database of installed services.
  118. [118]
    Get-Service (Microsoft.PowerShell.Management)
    The Get-Service cmdlet gets objects that represent the services on a computer, including running and stopped services.Syntax · Default (Default) · Description
  119. [119]
    Event Logging Operations - Win32 apps | Microsoft Learn
    Aug 14, 2025 · The OpenEventLog, OpenBackupEventLog, RegisterEventSource, DeregisterEventSource, and CloseEventLog functions open and close event log handles.