teamviewer.com link icon
or
Ask The Community

Remove settings during uninstall switch

Is it possible to add a switch to the uninstall command that will remove settings, which will then remove the TeamViewer folders? I am uninstalling TeamViewer via a script with ConnectWise Automate (formerly LabTech).

When I run this command in a script: "%programfiles(x86)%\TeamViewer\uninstall.exe" /S, it successfully removes TeamViewer, but leave the folders behind.

What can I add to my command line there that will remove the settings and folders?

-Mike

Comments

  • RCT_IT
    RCT_IT Posts: 36 ✭✭
    Hi mate,

    Feel free to grab some settings from my script ?

    =======================================================================SCRIPT
    =======================================================================

    ::Kills TeamViewer Services
    Taskkill /F /IM TeamViewer.exe
    Taskkill /F /IM TeamViewer_Service.exe

    ::Wait 5 seconds before next step
    TIMEOUT /T 5 /NOBREAK

    ::Kills TeamViewer Services again because they restart automatically
    Taskkill /F /IM TeamViewer.exe
    Taskkill /F /IM TeamViewer_Service.exe

    ::Uninstalls old MSI TeamViewer 14 Host v14.0.13880.0 silently
    MsiExec.exe /X{C0EF0E8A-161A-4F58-9CA1-AD66FE998DC9} /quiet

    ::Uninstalls old MSI TeamViewer 14 Host v14.1.3399.0 silently
    MsiExec.exe /X{33FA9C32-AD30-4121-8170-B4D880B71AD1} /quiet

    ::Uninstalls Old versions of TeamViewer silently
    "C:\Program Files\TeamViewer\uninstall.exe" /S
    "C:\Program Files (x86)\TeamViewer\uninstall.exe" /S

    ::Delete all leftover TeamViewer Registry keys
    REG DELETE HKLM\Software\TeamViewer /f
    REG DELETE HKCU\Software\TeamViewer /f
    REG DELETE HKLM\Software\Wow6432Node\TeamViewer /f

    ::Delete all leftover TeamViewer folders
    RD /S /Q %APPDATA%\TEAMVIEWER
    RD /S /Q %TEMP%\TEAMVIEWER
    RD /S /Q "C:\Program Files\Teamviewer"
    RD /S /Q "C:\Program Files (x86)\TeamViewer"

    ::This command specifies a wildcard to delete all old TeamViewer Shortcuts
    DEL /s /q /f "%PUBLIC%\Desktop\*TeamViewer*.lnk"
    DEL /s /q /f "%USERPROFILE%\*TeamViewer*.lnk"

    ::Installs TeamViewer Host silently
    TeamViewer_CustomRCT_Host_Setup.exe /S

    ::Loads TeamViewer specified settings in Registry.
    REGEDIT /S TV_Host_Settings.reg

    ::Wait 10 seconds before next step
    TIMEOUT /T 10 /NOBREAK

    setlocal ENABLEEXTENSIONS
    for /f "usebackq tokens=2,* delims= " %%a in (`net user "%USERNAME%" /domain ^| find /i "Full Name"`) do set FULLNAME=%%b
    echo %FULLNAME% > %temp%\fullname.txt

    PowerShell.exe -File "Create_TVBuddyDisplayName.ps1" -WindowStyle Hidden

    set KEY_NAME=HKCU\Software\TeamViewer
    set VALUE_NAME=BuddyDisplayName

    ::Turns the reg key value into a variable
    FOR /F "tokens=2*" %%A IN ('REG.exe query "%KEY_NAME%" /v "%VALUE_NAME%"') DO (set BUDDYDISPLAYNAME=%%B)

    ::This will assign TeamViewer silently to the group below after TeamViewer_Service.exe brings up TeamViewer.exe
    START /wait "Teamviewer Assignment" "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" assign --API-TOKEN 4827941-tk72SUsYIFeF0ThVAUqy --reassign --grant-easy-access --group "RCT Staff Machines" --alias "%BUDDYDISPLAYNAME% (%COMPUTERNAME%)"

    ::This will reload TeamViewer registry settings
    START /wait "Reload Settings" "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" --ReloadSettings

    ::This will restart TeamViewer which will re-assign the machine to the IT account
    NET STOP TeamViewer && NET START TeamViewer

    ::Kill the TV_Host_EXE_SOE.exe package
    Taskkill /F /IM TV_Host_EXE_SOE.exe

    ::Deletes all old versions of TeamViewer Setup files like TeamViewer Host, Full, etc.
    DEL /s /q /f "%USERPROFILE%\*TeamViewer*.exe"
    DEL /s /q /f "%USERPROFILE%\*TV_Host*.exe"
    DEL /s /q /f "%USERPROFILE%\*TV_Full*.exe"
    DEL /s /q /f "%TEMP%\fullname.txt"
    DEL /s /q /f "%TEMP%\Create_TVBuddyDisplayName.ps1"

    pause

    ::This Section needs to have a switch to check for if the installer was successful or not?
    ::DEL /f %TEMP%\TeamViewer_Host.log
  • kai_aretz
    kai_aretz Posts: 1

    Any idea of it?

Sign In or Register to comment.