Skip to content

Running the Scanner as a Windows Service

Overview

If your scanner is configured to handle its own schedule (e.g., via appsettings.ini), you can run TychoScanner.exe as a Windows Service. This allows the scanner to:

  • Start automatically when the system boots
  • Run silently in the background
  • Continuously execute scans based on the configured cron schedule
  • Avoid relying on Task Scheduler or manual execution

This is the preferred method when using the built-in schedule field in your configuration.

Prerequisites

  • TychoScanner.exe is installed and verified to work when run manually
  • TYCHODATA_OSPREY_APITOKEN is set as a User or System environment variable
  • The scanner configuration has schedule = */3 * * * * or similar enabled
  • Your user has Administrator access to install and manage services

Step-by-Step Setup

1. Create the Windows Service with PowerShell

You can use PowerShell to create a Windows service for TychoScanner.exe using the built-in New-Service cmdlet.

Install the service:

Open PowerShell as Administrator and run:

New-Service -Name "TychoDataOspreyScanner" -BinaryPathName "C:\Path\To\TychoScanner.exe" -DisplayName "Tycho Data Osprey Scanner Service" -Description "Runs Tycho Data Osprey Scanner as a Windows Service for scheduled data quality monitoring." -StartupType Automatic
  • Replace C:\Path\To\TychoScanner.exe with the actual path to your executable.
  • The service will be set to start automatically with Windows.

Set the Service Account (Optional):

If you need the service to run as a specific user (for example, to access PI or network resources), run:

$service = Get-WmiObject -Class Win32_Service -Filter "Name='TychoDataOspreyScanner'"
$service.Change($null, $null, $null, $null, $null, $null, "DOMAIN\\username", "password")
  • Replace DOMAIN\\username and password with the appropriate credentials.

2. Start the Service

Once installed, run:

Start-Service TychoDataOspreyScanner

Or from Services Manager:

  1. Press Windows + R, type services.msc, and press Enter
  2. Locate TychoDataOspreyScanner
  3. Right-click > Start

3. Set the Service to Auto-Start

This is already set by the -StartupType Automatic parameter, but you can verify in services.msc:

  1. Double-click TychoDataOspreyScanner
  2. Set Startup type to Automatic
  3. Click Apply

4. Remove the Service

If you need to uninstall the service, run the following command in PowerShell as Administrator:

Remove-Service -Name "TychoDataOspreyScanner"

If Remove-Service is not available (older PowerShell versions), use:

sc.exe delete "TychoDataOspreyScanner"

Best Practices

  • Restart the service to immediately trigger a run
  • Use a service account with the correct access to PI
  • Monitor logs to verify the scanner is operating as expected

When to Use This Approach

Use this method instead of Task Scheduler if:

  • You have performScan = true and schedule = ... in appsettings.ini
  • You want the scanner to survive reboots without user login