Skip to content

Instantly share code, notes, and snippets.

@edgarchinchilla
Last active April 16, 2020 00:51
Show Gist options
  • Save edgarchinchilla/74ee26f0a7e2058712cd027b6d49d836 to your computer and use it in GitHub Desktop.
Save edgarchinchilla/74ee26f0a7e2058712cd027b6d49d836 to your computer and use it in GitHub Desktop.
@ECHO OFF
TITLE Microsoft Teams Re-Installer
:: Credits
ECHO.
ECHO ::MS Herramienta de Reinstalaci¢n de Microsoft Teams, Copyleft 2020::
:: Global var definition
SET /A item=0
SET scriptTaskInfo[0]=01.-Cerrando aplicaciones...
SET scriptTaskInfo[1]=02.-Desinstalando Microsoft Teams...
SET scriptTaskInfo[2]=03.-Limpiando chach‚...
SET scriptTaskInfo[3]=04.-Iniciando aplicaciones nuevamente...
SET scriptTaskInfo[4]=05.-Reinstalando Microsoft Teams...
SET scriptTaskDone=Completado.
ECHO.
ECHO. Esta herramienta cerrar  temporalmente Outlook y Lync. Estas aplicaciones se abrir n nuevamente de forma autom tica al finalizar, no las abra manualmente.
ECHO.
:: Close Applications
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST false %scriptTaskInfo[0]%
SETLOCAL DisableDelayedExpansion
TASKKILL /F /IM outlook.exe
TASKKILL /F /IM lync.exe
TASKKILL /F /IM teams.exe
ping localhost -n 10 >null
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST true %scriptTaskInfo[0]% %scriptTaskDone%
SETLOCAL DisableDelayedExpansion
:: Uninstall
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST false %scriptTaskInfo[1]%
SETLOCAL DisableDelayedExpansion
%USERPROFILE%\AppData\Local\Microsoft\Teams\Update.exe --uninstall /s
ping localhost -n 45 >null
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST true %scriptTaskInfo[1]% %scriptTaskDone%
SETLOCAL DisableDelayedExpansion
:: Clean cache
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST false %scriptTaskInfo[2]%
SETLOCAL DisableDelayedExpansion
rmdir /Q /S "%USERPROFILE%\AppData\Local\Microsoft\Teams"
rmdir /Q /S "%USERPROFILE%\AppData\Local\Microsoft\TeamsMeetingAddin"
rmdir /Q /S "%USERPROFILE%\AppData\Local\Microsoft\TeamsPresenceAddin"
rmdir /Q /S "%USERPROFILE%\AppData\Roaming\Microsoft Teams"
rmdir /Q /S "%USERPROFILE%\AppData\Roaming\Microsoft\Teams"
ping localhost -n 5 >null
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST true %scriptTaskInfo[2]% %scriptTaskDone%
SETLOCAL DisableDelayedExpansion
:: Start Applications again
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST false %scriptTaskInfo[3]%
SETLOCAL DisableDelayedExpansion
START /MIN outlook.exe
START /MIN lync.exe
ping localhost -n 2 >null
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST true %scriptTaskInfo[3]% %scriptTaskDone%
SETLOCAL DisableDelayedExpansion
:: Reinstalling Teams
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST false %scriptTaskInfo[4]%
SETLOCAL DisableDelayedExpansion
cd %USERPROFILE%\Downloads
IF EXIST "Teams_windows_x64.exe" DEL /F /Q Teams_windows_x64.exe
certutil.exe -urlcache -split -f "https://go.microsoft.com/fwlink/p/?linkid=869426&lm=deeplink&lmsrc=groupchatmarketingpageweb&cmpid=directdownloadwin64" Teams_windows_x64.exe
ping localhost -n 5 >null
Teams_windows_x64.exe
ping localhost -n 5 >null
SETLOCAL EnableDelayedExpansion
CALL :ECHOHIST true %scriptTaskInfo[4]% %scriptTaskDone%
SETLOCAL DisableDelayedExpansion
GOTO :EXIT
:: Finish
:EXIT
ECHO.
ECHO Proceso finalizando, saliendo...
ping localhost -n 5 >null
:: Library for Start... Done. Messages
:ECHOHIST
REM Usage: CALL :ECHOHIST <replacelatest true|false> <param1> <param2> ... <param8>
SET _newMessage=%2 %3 %4 %5 %6 %7 %8 %9
IF "%1" == "true" (
SET /A discount=0
IF %item% GTR 0 SET /A discount=1
SET /A "prev=!item!-!discount!"
SET historicalEcho[!prev!]=!_newMessage!
GOTO :LOOP
) ELSE (
SET historicalEcho[!item!]=!_newMessage!
SET /A item+=1
GOTO :LOOP
)
GOTO :EOF
:COUNTARRAY
IF DEFINED historicalEcho[!cantidadItems!] (
SET /A "cantidadItems+=1"
GOTO :COUNTARRAY
)
GOTO :EOF
:LOOP
CLS
SET "cantidadItems=0"
CALL :COUNTARRAY
SET /A "cantidadItems-=1"
FOR /L %%i IN (0,1,!cantidadItems!) DO (
ECHO !historicalEcho[%%i]!
)
GOTO :EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment