Scripted installation

The Raygun APM Agent can be scripted to install silently and configured using the Raygun CLI tool for a complete automated setup process.

Install the APM Agent

Download the latest agent installer from the Agent downloads page and run the installer using the /quiet flag. Optionally you can output the installer log to a file which helps when diagnosing issues with the installation process.

# Run the installation using msiexec in quiet mode and no system restarts allowed,
# logging the output to a file
msiexec.exe /i RaygunAgent-x64.msi /quiet /norestart /log RaygunAgentInstall.log

Register the Agent and configure profiling

Part of the APM Agent installation will also install the CLI tool called rgc.exe. The CLI tool can be used to register the Agent with the Raygun API and enable/disable profiling of an application.

Note that the CLI tool is installed by default to %ProgramFiles(x86)%\Raygun\RaygunAgent\rgc.exe

# Register a new Agent installation with a default API key
rgc.exe -register <APP-API-KEY>

# Enable profiling of an IIS application using a specific API key
rgc.exe -enable <> -type IIS -apikey <APP-API-KEY>

PowerShell example script

The following example script will download the installer, install silently, register the Agent and enable profiling of the specified IIS applications.

Note that this must be run with administrator privileges.

# Configure where you want to download the installer
$installermsi = "${env:TEMP}\RaygunAgent-x64.msi"

# Configure your Raygun API key
$defaultapikey = "[YOUR-API-KEY]"

# Configure which IIS applications you want to profile and they API keys to use for them
$iisapps = @{
  "[]" = "[ALPHA-APP-API-KEY]"
  "[]" = "[BETA-APP-API-KEY]"

# rgc.exe will exist at this location after installation
$rgcli = "${env:Programfiles(x86)}\Raygun\RaygunAgent\rgc.exe"

# 1. Download the installer
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "" -OutFile $installermsi

# 2. Run the Agent installer silently
$args = "/i $installermsi","/quiet","/norestart","/log RaygunAgentInstall.log"
$exitcode = (Start-Process -FilePath msiexec.exe -ArgumentList $args -Wait -Passthru).ExitCode

Write-Host("Installation completed with exit code: $exitcode")

if ($exitcode -ne 0) {

# 3. Register the Agent with Raygun
$args = "-register $defaultapikey"
$exitcode = (Start-Process -FilePath $rgcli -ArgumentList $args -WindowStyle hidden -Wait -Passthru).ExitCode

Write-Host("Agent register completed with exit code: $exitcode")

if ($exitcode -ne 0) {

# 4. Enable profiling for the IIS application pools
foreach ($apppool in $iisapps.Keys) {
  $apikey = $iisapps[$apppool]
  $args = "-enable $apppool","-type iis","-apikey $apikey"
  $exitcode = (Start-Process -FilePath $rgcli -ArgumentList $args -WindowStyle hidden -Wait -Passthru).ExitCode

  Write-Host("Enable IIS $apppool completed with exit code: $exitcode")