﻿---
title: Configuration for Windows Services
description: Configuration for Windows services can be provided by setting environment variables for the specific Windows service in the Windows registry. With PowerShell...
url: https://docs-v3-preview.elastic.dev/elastic/apm-agent-dotnet/tree/main/reference/configuration-for-windows-services
---

# Configuration for Windows Services
Configuration for Windows services can be provided by setting environment variables for the specific Windows service in the Windows registry. With PowerShell
```powershell
$environment = [string[]]@(
  "ELASTIC_APM_SERVER_URL=http://localhost:8200", 
  "ELASTIC_APM_TRANSACTION_SAMPLE_RATE=1",
  "ELASTIC_APM_ENVIRONMENT=Production",
  "ELASTIC_APM_SERVICE_NAME=MyWindowsService")

Set-ItemProperty HKLM:SYSTEM\CurrentControlSet\Services\<service-name> -Name Environment -Value $environment 
```

The service must then be restarted for the change to take effect
```powershell
Restart-Service <service-name>
```