Service Resource
Synopsis
Manages Windows services, including start type, status, and service configuration.
Type
Capabilities
- Get
- Set
- Delete
- Export
Properties
name
The service name (not display name).
displayName
The display name of the service.
description
The service description.
path
The path to the service executable.
dependencies
Service dependencies.
status
Desired status. Accepts Running, Stopped, or Paused.
startType
Start type. Accepts Automatic, Manual, or Disabled.
_exist
Whether the service should exist.
Note
This resource requires administrator privileges.
Examples
Example 1 — Ensure a service is running
Example 2 — Configuration document
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Ensure Print Spooler is running
type: OpenDsc.Windows/Service
properties:
name: Spooler
status: Running
startType: Automatic
- name: Disable Remote Registry
type: OpenDsc.Windows/Service
properties:
name: RemoteRegistry
status: Stopped
startType: Disabled
Exit codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Invalid JSON |
| 3 | Windows API error |
| 4 | Invalid argument or missing required parameter |
| 5 | Invalid operation or service state |
| 6 | Service operation timed out |