Uninstall TeamViewer Using Group Policies

When looking at GPO to uninstall software the answer is really simple. Group Policies can only uninstall software that was installed via Group Policies. Well even though this statement remains true we can still use Group Policies to run PowerShell Scripts or BAT files. These files in turn can be run by Group Policies to uninstall software like TeamViewer.

Even though the below is not limited to TeamViewer this can not be assumed that it will work other software and tests will still need to be made prior to rolling out the GPO.

The Script

The below script is done in Command Prompt and should work with most Client based Windows Machine. Even thought this was only tested on Windows 7 and Windows 10.

TeamViewer stores a lot of the config files in the Registry. This includes the installation location. The reason this is important is when you have different versions of TeamViewer you will have different folder Locations.

You can use the reg query command to find the InstallDirectory This Directory can then be stored as a variable where it can then be used to browse to the Directory and use the Silent Uninstall feature.

The code can be copied and pasted into a Text File and saved as a .BAT File.

For /F "tokens=1,2 delims=REG_SZ" %%G in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\TeamViewer /f InstallationDirectory ^| findstr InstallationDirectory') do set Loc=%%H
cd %Loc%
uninstall.exe /S

If you want more info on how the For Loop works in Command Prompt you can click here


The Group Policy is fairly Straight forward to create. When opening the Group Policy Management editor, you create a new Policy with the correct Naming as per your Organization Setup. In the case below I used the following Naming convention.

CC – Computer Configuration
App: – This will make changes to a Specific App
Uninstall TeamViewer – What changes will be made to the App.

Once Created, edit the new GPO. Choose the path:
Computer Configuration >> Policies >> Windows Settings >> Scripts (Startup/Shutdown). Double click Startup.

Uninstall TeamViewer Using Group Policies

In the Startup, Menu Add the script. The Script can be placed in the Domain Policy Folder. The Domain Policy folder path can be found by Clicking on Show Files…

Uninstall TeamViewer Using Group Policies

When the script has been placed in the correct location. Click the Add button and Browse… Once select press OK until all Menu are closed.

Uninstall TeamViewer Using Group Policies

From here like normal assign the Policy to the relevant Organizational Unit.


If you liked what you read Please Share.
I’d love it if you followed me on YouTube and Facebook.

Also, feel free to subscribe to my posts by email.
Donations for the site can be made here.
Thanks for reading.

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *