Announcements
Highlighted
Posted by DASHealth
Henagon

Received Batch From Teamviewer and it's not working correctly

Below is the batch file I received earlier.  I put it and the TeamViewer_Host.msi file in the same directory.  I also changed the ID and Token for our client.  I tried running it and in uninstalls Teamviewer, but when it goes to install it just sits there and I get the following.  As a side note, I'm unable to reinstall Teamviewer as it errors out on me and now I'm stuck.  Thanks!!

No Instance(s) Available.
ERROR: The system was unable to find the specified registry key or value.
The system cannot find the file specified.
Installing TeamViewer14

 

REM         SET VARIABLES VALUES
SET configid= ########
SET token=####################################################

@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------

tasklist /FI "IMAGENAME eq TeamViewer.exe" 2>NUL | find /I /N "TeamViewer.exe">NUL
if "%ERRORLEVEL%"=="0" (GOTO :KILL) ELSE (GOTO :REMOVEMSI)

:KILL
taskkill /f /im TeamViewer.exe
TIMEOUT 2
GOTO :REMOVEMSI

:REMOVEMSI
wmic product where vendor="TeamViewer"
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
cd\
Set "OS64=C:\Program Files (x86)"
IF EXIST "%OS64%" (GOTO :UNINSTALL64) ELSE (GOTO :UNINSTALL32)

:UNINSTALL64
cd\
Set "OLD64=C:\Program Files (x86)\TeamViewer\Version*"
IF EXIST "%OLD64%" (GOTO :PREVIOUS64) ELSE (GOTO :REMOVE64)

:UNINSTALL32
cd\
Set "OLD32=C:\Program Files\TeamViewer\Version*"
IF EXIST "%OLD32%" (GOTO :PREVIOUS32) ELSE (GOTO :REMOVE32)

:PREVIOUS32
cd\
cd %ProgramFiles%\TeamViewer\Version*
IF NOT EXIST "*uninstall*" GOTO :REMOVE32
start uninstall.exe /S
GOTO :REMOVE32

:REMOVE32
cd\
cd %ProgramFiles%\TeamViewer
IF NOT EXIST "*uninstall*" GOTO :REMOVEFILES32
start uninstall.exe /S
GOTO :REMOVEFILES32

:REMOVEFILES32
reg delete "HKLM\Software\TeamViewer" /f
cd %temp%
rd TeamViewer /s /Q
GOTO :INSTALL

:PREVIOUS64
cd\
cd %ProgramFiles(x86)%\TeamViewer\Version*
IF NOT EXIST "*uninstall*" GOTO :REMOVE64
start uninstall.exe /S
GOTO :REMOVE64

:REMOVE64
cd\
cd %ProgramFiles(x86)%\TeamViewer
IF NOT EXIST "*uninstall*" GOTO :REMOVEFILES64
start uninstall.exe /S
GOTO :REMOVEFILES64

:REMOVEFILES64
reg delete "HKLM\Software\Wow6432Node\TeamViewer" /f
cd %temp%
rd TeamViewer /s /Q
GOTO :INSTALL

:INSTALL
echo Installing TeamViewer14
setlocal
cd /D "%~dp0"
start /wait msiexec.exe /i TeamViewer_Host.msi /qn customconfigid=%configid% apitoken=%token% assignmentoptions="--alias %computername% --grant-easy-access"
exit