Restart RSLinx in Service Mode Using a Scheduled Task
Automatically restart the RSLinx service each night to prevent communication dropouts in Rockwell environments
This procedure creates a Windows Scheduled Task that silently restarts the Rockwell RSLinx service once per day (default: 2:00 AM). This can help resolve intermittent communication issues by ensuring RSLinx is refreshed on a regular basis.
Prerequisites
- Local administrator rights
- PowerShell available (default on modern Windows)
Steps:
1) Confirm the following directory exists, and if not, create it: "C:\ProgramData\Copia Automation"
2) Open Notepad, paste the script provided below, and save it as “C:\ProgramData\Copia Automation\RSLinxServiceRestart.ps1”
# RSLinx Management Script
# ─────────────────────────────────────────
# STEP 0: Self-elevate to Administrator when running in manual mode (Uncomment to run)
# ─────────────────────────────────────────
#if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
# Start-Process PowerShell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Path)`"" -Verb RunAs
# exit
#}
# ─────────────────────────────────────────
# Logging Setup
# ─────────────────────────────────────────
$ScriptFolder = Split-Path -Parent $MyInvocation.MyCommand.Path
$LogFolder = Join-Path $ScriptFolder "RSLinx Classic Service Restart Logs"
$LogFile = Join-Path $LogFolder "RSLinx_$(Get-Date -Format 'yyyy-MM-dd_HH-mm-ss').txt"
if (-not (Test-Path $LogFolder)) { New-Item -ItemType Directory -Path $LogFolder -Force }
# Keep only the last 7 logs (one per day = one week)
Get-ChildItem -Path $LogFolder -Filter "RSLinx_*.txt" |
Sort-Object LastWriteTime -Descending |
Select-Object -Skip 7 |
Remove-Item -Force
Start-Transcript -Path $LogFile -Append
Write-Host "=== RSLinx Management Script ==="
Write-Host "Run Time: $(Get-Date)"
Write-Host "Running as: $([Security.Principal.WindowsIdentity]::GetCurrent().Name)"
# ─────────────────────────────────────────
# STEP 1: Stop RSLinx application if running
# ─────────────────────────────────────────
Write-Host "`n[1] Checking for running RSLinx processes..."
$processes = Get-Process | Where-Object {
$_.ProcessName -like "*rslinx*" -or $_.ProcessName -like "*rslinxclassic*"
}
if ($processes) {
Write-Host " Found $($processes.Count) process(es). Stopping..."
$processes | Stop-Process -Force
Start-Sleep -Seconds 2
Write-Host " RSLinx processes stopped."
} else {
Write-Host " No RSLinx processes found running."
}
# ─────────────────────────────────────────
# STEP 2: Start RSLinx Service
# ─────────────────────────────────────────
Write-Host "`n[2] Starting RSLinx service..."
try {
Start-Service -Name "RSLinx" -ErrorAction Stop
Write-Host " RSLinx service started successfully."
} catch {
Write-Host " ERROR: Could not start RSLinx service."
Write-Host " $_"
}
# ─────────────────────────────────────────
# STEP 3: Set RSLinx Service to Automatic startup
# ─────────────────────────────────────────
Write-Host "`n[3] Configuring RSLinx service to start automatically..."
try {
Set-Service -Name "RSLinx" -StartupType Automatic -ErrorAction Stop
Write-Host " RSLinx startup type set to Automatic."
} catch {
Write-Host " ERROR: Could not configure startup type."
Write-Host " $_"
}
# ─────────────────────────────────────────
# SUMMARY
# ─────────────────────────────────────────
Write-Host "`n=== Done ==="
$svc = Get-Service -Name "RSLinx" -ErrorAction SilentlyContinue
if ($svc) {
Write-Host " Service Status : $($svc.Status)"
Write-Host " Startup Type : $($svc.StartType)"
}
Stop-Transcript
3) Open Command Prompt as Administrator and run the command below. The default run time is 02:00 (2 AM). To change it, modify /ST to your preferred time (24-hour format)
schtasks /Create /TN "RSLinx Daily Restart" /TR "powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -File \"C:\ProgramData\Copia Automation\RSLinxServiceRestart.ps1\"" /SC DAILY /ST 02:00 /RL HIGHEST /RU SYSTEM
What This Does
- Creates a scheduled task named “RSLinx Daily Restart”
- Runs once per day
- Executes your PowerShell script silently (no visible window)
- The task runs as System context by default
- Creates a log file for the last 7 days
- If needed, the task can be modified in Task Scheduler (taskschd.msc)