---
title: TwinCAT / Beckhoff complete uninstall script
title_en: TwinCAT / Beckhoff complete uninstall script
description: A PowerShell script to batch-uninstall every Beckhoff TwinCAT-related component. Useful when you need a clean reinstall or full removal.
sidebar_label: TwinCAT complete uninstall
---

# TwinCAT / Beckhoff complete uninstall PowerShell script

## Problem

A TwinCAT install leaves a lot of Beckhoff components on the system (XAE, XAR, TC3 Functions, drivers, etc.). Uninstalling them one by one through Control Panel is slow and easy to miss entries. When you need a clean removal — version conflict, pre-reinstall cleanup — doing it manually isn't practical.

## Environment

- Windows 10 / 11
- PowerShell 5.1+ (built in)
- Requires **administrator privileges**

## Solution

Open PowerShell as administrator and run:

```powershell
$RegKeys = @(
    'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'
    'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\'
)

$Apps = $RegKeys |
    Get-ChildItem |
    Get-ItemProperty |
    Where-Object { $_.DisplayName -like 'Beckhoff*' -and $_.UninstallString }

# List what will be uninstalled first — sanity check
$Apps | Select-Object DisplayName, UninstallString

# Once you've confirmed the list, run this part
foreach ($App in $Apps) {
    $UninstallString = if ($App.UninstallString -match '^msiexec') {
        "$($App.UninstallString -replace '/I', '/X') /qn /norestart"
    } else {
        $App.UninstallString
    }
    Write-Host "Uninstalling: $($App.DisplayName)" -ForegroundColor Yellow
    Start-Process -FilePath cmd -ArgumentList '/c', $UninstallString -NoNewWindow -Wait
    Write-Host "Done: $($App.DisplayName)" -ForegroundColor Green
}
```

### How it works

1. Scans the `Uninstall` registry keys (covering both 64-bit and 32-bit paths)
2. Filters entries whose `DisplayName` starts with `Beckhoff` and that have an `UninstallString`
3. The first block lists matches so you can confirm and avoid removing the wrong thing
4. The second block uninstalls each one: MSI-based components are converted to silent uninstall (`/X ... /qn /norestart`); non-MSI entries run their original uninstall command

### Notes

- Run the listing part first (stop at `Select-Object`) to make sure nothing unintended is matched
- The uninstall can take several minutes depending on how many components are installed
- Reboot after it finishes so driver and service removals take effect
- If TwinCAT services are running, stop the `TcSysSrv` service before uninstalling
