Need Help Uninstalling and Re-installing Microsoft Teams

I’m trying to uninstall Teams on a Windows computer and then install the latest Teams version. I’ve got the following action script which completes successfully with no errors yet the old Teams remains after it runs. Any insight on this would be greatly appreciated. Examples help as well.

begin prefetch block
add prefetch item name=0fd7bea42350051fbf6b696846a4c0138849f632 sha1=0fd7bea42350051fbf6b696846a4c0138849f632 size=144490496 url=SWDProtocol://127.0.0.1:52311/Uploads/0fd7bea42350051fbf6b696846a4c0138849f632/Teams_windows_x64.msi.bfswd sha256=1e52b910661fb5fa1788ecec110d6a7da60969387109ebc8fca0dff82117b00a
end prefetch block

// All SWD files will go into a folder in the clients __BESData folder. This folder gets cleared on every restart.
parameter “baseFolder” = “__Download/”
// Move files into subfolders and unescape file names
move “__Download/0fd7bea42350051fbf6b696846a4c0138849f632” “{parameter “baseFolder”}Teams_windows_x64.msi”

waithidden msiexec.exe /x “__Download\Teams_windows_x64.msi” /qn /norestart

waithidden msiexec.exe /i “__Download\Teams_windows_x64.msi” /qn

yeah you probably can’t use the new install file to uninstall the old version. Get the uninstallstring from the registry, it’s usually going to point to some GUID. Depending on your windows clients 32 or 64 bit it could be in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall or HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall keys.

1 Like

According to what information Microsoft makes available, Teams cannot be updated administratively:

“Teams doesn’t give admins the ability to deploy updates through any delivery mechanism.”
(from https://learn.microsoft.com/en-us/microsoftteams/teams-client-update)

All Teams installations are User-level installations, not System-level installations. The software runs from each user’s AppData directory. What is installed with Office is actually an installer, not the application itself.

In order to remove Teams, you’ll likely have to remove Office entirely from the system.

I wrote up an article about this for our local IT admins here at Duke if you’re interested:

Ok so try the quietuninstallstring from HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Teams (with a constraint checking for logged on user)

Emulating a manual uninstall reinstall is not the same as an in place update.

1 Like

so this is what I’ve created. When I tested it I got a message that it failed but that might have more to do with my success criteria than anything. It does appear to have uninstalled Teams but the icon remains on the desktop and the listing still appears in the uninstall list but the icon is greyed out. So it more or less half worked? Maybe there’s a more eloquent way to do this?

delete __createfile
createfile until END
@echo off
taskkill /F /IM teams.exe
"C:\Users\Administrator\AppData\Local\Microsoft\Teams\Update.exe" --uninstall -s
END
delete uninstall.bat
move __createfile uninstall.bat
waithidden uninstall.bat >> uninstall.log 2>&1

image

that only works if it was installed under the administrator’s account, you’d have to make relevance that checks for the right context, or make the actionscript dependent on different scenarios

for instance this is how I did a generic wireshark uninstall (as native powershell, not actionscript! Which only works on later BES versions)

stop-process -name dumpcap -Force
stop-process -name Wireshark -Force
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"

$app = Get-ChildItem -Path $RegPath | Get-ItemProperty | Where-Object {$_.DisplayName -match "Wireshark" }
$app.QuietUninstallString | cmd

You could then replace the $RegPath with like HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Teams (because it’s not a GUID you don’t have to search for it)

But yeah don’t forget to create a relevance condition to this that checks whether the current logged on user has the file present in their appdata and the actionscript uses current user context or it won’t work.

(Sorry I’ve edited this like half a dozen times, I have a very scattered brain and have to read through things to see important things I’ve failed to communicate.)

2 Likes

I wrote a script to totally remove MS Teams and then re-install for user using generic installation file that I uploaded to my environment:

[I’m sure it can be written better]

//Clear the environment
delete __appendfile
if {exist file “c:\TEMP\teamsu.bat”}
delete c:\TEMP\teamsu.bat
endif
if {exist file “c:\TEMP\teamsr.bat”}
delete c:\TEMP\teamsr.bat
endif

//Uninstall Teams
appendfile taskkill /IM teams.exe /F
appendfile {"%22"&concatenation “%22 --uninstall%0d%0a%22” of (pathnames of files “Update.exe” of folders “AppData\Local\Microsoft\Teams” of folders of folders “C:\Users”)&"%22 --uninstall"}

move __appendfile c:\TEMP\teamsu.bat
if {exist file “c:\TEMP\teamsu.bat”}
waithidden c:\TEMP\teamsu.bat
endif

//clean appendfile
delete __appendfile

//Delete leftovers from all users appdata
appendfile ## del leftovers ##
if {exist (pathname of it) of folders whose (name of it as lowercase contains “teams”) of folders of folders “AppData” of folders of folders “C:\Users”}
appendfile {“RD /S /Q %22” & concatenation “%22%0d%0aRD /S /Q %22” of ((pathname of it) of folders whose (name of it as lowercase contains “teams”) of folders of folders “AppData” of folders of folders “C:\Users”)& “%22”}
endif

if {exist (pathname of it) of folders whose (name of it as lowercase contains “teams”) of folders of folders of folders “AppData” of folders of folders “C:\Users”}
appendfile {“RD /S /Q %22” & concatenation “%22%0d%0aRD /S /Q %22” of ((pathname of it) of folders whose (name of it as lowercase contains “teams”) of folders of folders of folders “AppData” of folders of folders “C:\Users”)& “%22”}
endif

move __appendfile c:\TEMP\teamsr.bat
if {exist file “c:\TEMP\teamsr.bat”}
waithidden c:\TEMP\teamsr.bat
endif

//Clear the environment
delete __appendfile
if {exist file “c:\TEMP\teamsu.bat”}
delete c:\TEMP\teamsu.bat
endif
if {exist file “c:\TEMP\teamsr.bat”}
delete c:\TEMP\teamsr.bat
endif

prefetch //your setup upload// extract to c:\TEMP
override wait
Hidden=true
RunAs=currentuser
wait c:\TEMP\TeamsSetup_c_w_.exe

1 Like