@echo off

set EXE=%SystemDrive%\tools\software\teams-setup.exe

if NOT EXIST %EXE% (
  echo ERROR: %EXE% not found!
  exit /b
)

echo ####### %0 #######

echo killing Teams process ...
taskkill /F /IM teams.exe 2>nul
timeout /nobreak 5

echo cleaning cache ...
deltree "%USERPROFILE%\AppData\Roaming\Microsoft\Teams"
deltree "%USERPROFILE%\AppData\Local\Microsoft\Teams"
deltree "%USERPROFILE%\AppData\Local\Microsoft\TeamsMeetingAddin"
deltree "%USERPROFILE%\AppData\Local\Microsoft\TeamsPresenceAddin"

echo installing Microsoft Teams ...
start /wait %EXE% -s

echo renaming Teams desktop link ...
move /Y "%USERPROFILE%\Desktop\Microsoft Teams.lnk" "%USERPROFILE%\Desktop\Teams.lnk"

rem refresh desktop (W10 style)
ie4uinit.exe -show

echo ####### %0 #######
pause

