@echo off
CLS
echo ===========================
echo Update and run TeamViewerQS
echo ===========================
if exist %windir%\System32\wget.exe goto runWget
::::::::::::::::::::::::::::::::::::::::::::
:: Elevate.cmd - Version 4
:: Automatically check & get admin rights
:: see "
https://stackoverflow.com/a/12264592/1016343" for description
::::::::::::::::::::::::::::::::::::::::::::
ECHO.
:init
setlocal DisableDelayedExpansion
set cmdInvoke=1
set winSysFolder=System32
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
if '%cmdInvoke%'=='1' goto InvokeCmd
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
goto ExecElevation
:InvokeCmd
ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
:ExecElevation
"%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
REM Everything below runs elevated ("as admin")
echo This script requires Wget to update Teamviewer QS. It was not found in %windir%\System32.
echo.
echo Your default Internet Browser will open next. Please download the latest EXE
echo version for your Windows - most likely 64bit, but if you're unsure 32bit -
echo to your DOWNLOADS folder. This script will then proceed automatically.
rem echo Once you've done that, you NEED to return to this Window (for example by minimizing or closing your Browser)!
echo.
pause
rem start iexplore "
https://eternallybored.org/misc/wget"
rem explorer "
https://eternallybored.org/misc/wget"
rem start /max
https://eternallybored.org/misc/wgetrundll32 url.dll,FileProtocolHandler
https://eternallybored.org/misc/wgetecho.
echo Waiting now patiently for wget.exe to appear in your Downloads folder...
rem pause
:waitForWgetLoop
timeout 2 /NOBREAK
if not exist %userprofile%\Downloads\wget.exe goto waitForWgetLoop
move %userprofile%\Downloads\wget.exe %windir%\System32
:runWget
rem cd /d %~dp0
rem cd /D %systemdrive%%homepath%\Downloads
rem cd /D %HOMEDRIVE%%homepath%\Downloads
cd /D %userprofile%\Downloads
rem wget --spider -S
http://download.teamviewer.com/download/TeamViewerQS.exerem wget --no-check-certificate -O TeamViewerQS.exe
http://download.teamviewer.com/download/TeamViewerQS.exerem wget -N
http://download.teamviewer.com/download/TeamViewerQS.exewget -N --no-check-certificate
http://download.teamviewer.com/download/TeamViewerQS.exestart "" TeamViewerQS.exe