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:
$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
- Scans the
Uninstallregistry keys (covering both 64-bit and 32-bit paths) - Filters entries whose
DisplayNamestarts withBeckhoffand that have anUninstallString - The first block lists matches so you can confirm and avoid removing the wrong thing
- 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
TcSysSrvservice before uninstalling