Skip to content

Instantly share code, notes, and snippets.

@koosvanw
Last active November 22, 2024 09:19
Show Gist options
  • Save koosvanw/5b6933945399ec727b61531de7a6a794 to your computer and use it in GitHub Desktop.
Save koosvanw/5b6933945399ec727b61531de7a6a794 to your computer and use it in GitHub Desktop.
Boxstarter script to remove TwinCAT 3 packages from your computer

Contents

This gist contains a boxstarter script to remove TwinCAT 3.1 from your computer, including the following additional packages:

  • TwinCAT 3.1 engineering modules
  • TwinCAT 3 measurement
  • Remote Manager 4022 and 4024 installations
  • TF5400 Kinematic transformation

It should allow you to more easily wipe TwinCAT 3 from your pc.

Notes

  • It will not cleanup the registry
  • It will not cleanup any local cache locations / temporary files
  • Use at your own risk!

Usage

You can run the script using BoxStarter, see https://boxstarter.org/

Or simply use this link: Uninstall TwinCAT

function RebootIfRequired(){
if (Test-PendingReboot) {
Invoke-Reboot
}
}
$keys = Get-Package -Provider Programs -IncludeWindowsInstaller -Name "Beckhoff TF5400 *" -ErrorAction SilentlyContinue
foreach($key in $keys)
{
$package = $key.Name
Uninstall-Package -Name "$package"
}
RebootIfRequired
$keys = Get-Package -Provider Programs -IncludeWindowsInstaller -Name "Beckhoff TwinCAT 3.1 Remote Manager *" -ErrorAction SilentlyContinue
foreach($key in $keys)
{
$package = $key.Name
Uninstall-Package -Name "$package"
RebootIfRequired
if(Test-PendingReboot){
break
}
}
# Removing TwinCAT 3 Measurement requires a different approach, it doesn't respond to `Uninstall-Package`. Instead,
# get the uninstall string from the registry and call that command.
$app = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -eq "Beckhoff TwinCAT 3 Measurement"
if ($null -ne $app)
{
$command = $app.UninstallString
$split = $command.Split('"')
Start-Process $split[1] -ArgumentList $split[2] -Wait
}
RebootIfRequired
# Separate package list in 2 in order to force a reboot in between.
$keys = @('Beckhoff Support Info Report',
'Beckhoff Target Browser',
'Beckhoff TE130x Scope View',
'Beckhoff TE132x Bode Plot',
'Beckhoff TE9000 TwinSAFE Editor',
'Beckhoff TF3110 TC3 Filter Designer',
'Beckhoff TF3300 Scope Server',
'Beckhoff TwinCAT 3 Application Runtime Libraries (x64)',
'Beckhoff TwinCAT 3 BlockDiagram')
$keys2 = @('Beckhoff TwinCAT 3 Measurement Base',
'Beckhoff TwinCAT 3 Type System (x64)',
'Beckhoff TwinCAT 3 x64 Driver Package',
'Beckhoff TwinCAT MultiUser',
'Beckhoff TwinCAT MultiUser Git',
'Beckhoff TwinCAT PnP Driver Package',
'Beckhoff TwinCAT XAE Shell',
'Beckhoff TwinCAT Embedded Browser',
'Beckhoff TwinCAT 3.1 (Build 4024)',
'Beckhoff TwinCAT 3 Measurement',
'Beckhoff TwinCAT AML DataExchange')
foreach($key in $keys)
{
if ($null -ne (Get-Package -Provider Programs -IncludeWindowsInstaller -Name "$key" -ErrorAction SilentlyContinue)){
Uninstall-Package -Name "$key"
RebootIfRequired
if(Test-PendingReboot){
break
}
}
}
RebootIfRequired
foreach($key in $keys2)
{
if ($null -ne (Get-Package -Provider Programs -IncludeWindowsInstaller -Name "$key" -ErrorAction SilentlyContinue)){
Uninstall-Package -Name "$key"
RebootIfRequired
if(Test-PendingReboot){
break
}
}
}
# Remove any remaining items starting with "Beckhoff " from Programs and Features
$keys = Get-Package -Provider Programs -IncludeWindowsInstaller -Name "Beckhoff *" -ErrorAction SilentlyContinue
foreach($key in $keys)
{
$package = $key.Name
Uninstall-Package -Name "$package"
RebootIfRequired
if(Test-PendingReboot){
break
}
}
RebootIfRequired
Remove-Item -Path "$env:programdata\Beckhoff" -Force -Recurse
Remove-Item -Path "${env:programfiles(x86)}\Beckhoff" -Force -Recurse
Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Beckhoff\TwinCAT3" -Force -Recurse
Remove-Item -Path "C:\TwinCAT\3.1" -Force -Recurse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment