Hi,
This is something I keep bouncing into everytime I want to upgrade TeamViewer.
The old TV version is removed, the new TV version is installed but the system looses connectivity again to the portal and I can't connect to a system unattended anymore but always need to enter a password.
We also set in our policy that users are unable to close TeamViewer, but that is lost as well.
If however I uninstall TeamViewer and install it again using the exact same script then the policy is assigned.
This is very frustrating. How can I make sure that every system keeps it's assignment when updated.
We use MS Config Manager for automatic updates for Teamviewer.
See the script below.
@echo off
REM SET VARIABLES VALUES
SET MSIFilePath=\TeamViewer_Host.msi
SET MSILogPath=%Temp%\TVHOSTMSI.log
SET MYDIR=%cd%
ECHO The current working folder is %MYDIR%
REM regional settings EU
SET configid=<MYCONFIGID>
SET token=<MYAPITOKEN>
ECHO UNINSTALL CURRENT TEAMVIEWER INSTALLATION
tasklist /FI "IMAGENAME eq TeamViewer.exe" 2>NUL | find /I /N "TeamViewer.exe">NUL
if "%ERRORLEVEL%"=="0" (GOTO :KILL) ELSE (GOTO :REMOVEMSI)
:KILL
ECHO Kill Teamviewer process
taskkill /f /im TeamViewer.exe
timeout /t 5
GOTO :REMOVEMSI
:REMOVEMSI
wmic product where vendor="TeamViewer"
if "%errorlevel%"=="0" GOTO :CHECKOSSETUP
if not "%errorlevel%"=="0" GOTO :CHECKOS
for /f "tokens=2 delims==" %%f in ('wmic product Where "vendor like 'TeamViewer'" get IdentifyingNumber /value ^| find "="') do set "id=%%f"
msiexec.exe /x "%id%" /qn
GOTO :CHECKOS
:CHECKOS
ECHO checking OS
cd\
Set "OS64=C:\Program Files (x86)"
IF EXIST "%OS64%" (GOTO :UNINSTALL64) ELSE (GOTO :UNINSTALL32)
:UNINSTALL64
ECHO running x64 uninstaller
cd\
Set "OLD64=C:\Program Files (x86)\TeamViewer\Version*"
IF EXIST "%OLD64%" (GOTO :PREVIOUS64) ELSE (GOTO :REMOVE64)
:UNINSTALL32
ECHO running x86 uninstaller
cd\
Set "OLD32=C:\Program Files\TeamViewer\Version*"
IF EXIST "%OLD32%" (GOTO :PREVIOUS32) ELSE (GOTO :REMOVE32)
:PREVIOUS32
ECHO removing older x86 versions
cd\
cd %ProgramFiles%\TeamViewer\Version*
IF NOT EXIST "*uninstall*" GOTO :REMOVE32
start uninstall.exe /S
GOTO :REMOVE32
:REMOVE32
ECHO removing current x86 versions
cd\
cd %ProgramFiles%\TeamViewer
IF NOT EXIST "*uninstall*" GOTO :REMOVEFILES32
start uninstall.exe /S
GOTO :REMOVEFILES32
:REMOVEFILES32
ECHO removing x86 registry keys
reg delete "HKLM\Software\TeamViewer" /f
cd %temp%
REM removing x86 folders
rd TeamViewer /s /Q
GOTO :INSTALL
:PREVIOUS64
ECHO removing older x64 version
cd\
cd %ProgramFiles(x86)%\TeamViewer\Version*
IF NOT EXIST "*uninstall*" GOTO :REMOVE64
start uninstall.exe /S
GOTO :REMOVE64
:REMOVE64
ECHO removing current x64 version
cd\
cd %ProgramFiles%\TeamViewer
IF NOT EXIST "*uninstall*" GOTO :REMOVEFILES64
start uninstall.exe /S
GOTO :REMOVEFILES64
:REMOVEFILES64
ECHO removing x64 Registry keys
reg delete "HKLM\Software\Wow6432Node\TeamViewer" /f
reg delete "HKLM\Software\WOW6432Node\TVInstallTemp" /f
cd %temp%
rd TeamViewer /s /Q
GOTO :INSTALL64
:CHECKOSSETUP
ECHO check OS version
cd\
Set "OS64=C:\Program Files (x86)"
IF EXIST "%OS64%" (GOTO :INSTALL64) ELSE (GOTO :INSTALL32)
:INSTALL64
ECHO Check for leftovers in registry
@"%__AppDir__%WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Command "Get-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Installer\Products\*' -Name 'ProductName' -ErrorAction SilentlyContinue | ForEach-Object { If ($_.ProductName -like 'Teamviewer * Host') { Remove-Item -Path $_.PSPath -Recurse } }"
ECHO install new x64 version
CD %MYDIR%
ECHO %CD%
timeout /t 15
msiexec /i "%~dp0TeamViewer_Host.msi" /q CUSTOMCONFIGID=6usbyqk
ECHO Teamviewer installed - wait 30 seconds for setup to complete
timeout /t 30
GOTO :ASSIGNx64
:INSTALL32
ECHO Check for leftovers in registry
@"%__AppDir__%WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Command "Get-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Installer\Products\*' -Name 'ProductName' -ErrorAction SilentlyContinue | ForEach-Object { If ($_.ProductName -like 'Teamviewer * Host') { Remove-Item -Path $_.PSPath -Recurse } }"
ECHO install new x86 version
CD %MYDIR%
msiexec /i "%~dp0TeamViewer_Host.msi" /q CUSTOMCONFIGID=6usbyqk
ECHO Teamviewer installed - wait 30 seconds for setup to complete
timeout /t 30
GOTO :ASSIGNx86
:ASSIGNx64
ECHO Kill Teamviewer process
taskkill /f /im TeamViewer.exe
timeout /t 5
ECHO Assign the Teamviewer policy
"C:\Program Files (x86)\TeamViewer\TeamViewer.exe" assign --api-token <MYAPITOKEN> --group-id <MYGROUPID> --reassign --alias %COMPUTERNAME% --grant-easy-access
timeout /t 20
"C:\Program Files (x86)\TeamViewer\TeamViewer.exe"
GOTO :EXIT
:ASSIGNx86
ECHO Kill Teamviewer process
taskkill /f /im TeamViewer.exe
timeout /t 5
ECHO Assign the Teamviewer policy
"C:\Program Files\TeamViewer\TeamViewer.exe" assign --api-token <MYAPITOKEN> --group-id <MYGROUPID> --reassign --alias %COMPUTERNAME% --grant-easy-access
timeout /t 20
"C:\Program Files\TeamViewer\TeamViewer.exe"
GOTO :EXIT
:EXIT
ECHO Finalising Teamviewer installation.
timeout /t 10
EXIT