Microsoft released a windows installer for Teams that is placed in Program Files, but this is theoretically targeted only for VDI (Virtualized Desktop Infrastructure).
The Teams MSI installer can be downloaded from these links:
To install Teams for all users, the following command should be used:
msiexec /i “PathToMsi” ALLUSER=1
DO NOT MISTAKE ALLUSER=1 WITH THE GENERAL PROPERTY ALLUSERS=1, THERE IS A MISSING “S” IN THERE.
However, if you try to install this on a normal Windows 10 machine, you will be presented with the error “Cannot install for all users when a VDI environment is not detected.”
Diving into the MSI, we observe that the MSI is actually just a wrapper for Teams.exe that is placed in C:\Program Files(x86)\Teams Installer and executed via the custom action RunInstalledExecutable with the command line –allusers.
Launch conditions or Custom Actions to check if the machine is VDI are not present in the MSI, so this check is done from the actual Teams.exe installer.
After a few investigations i discover that the Teams.exe installer searches for a registry in HKEY_LOCAL_MACHINE\Software\Citrix\PortICA. Creating that specific registry tricks Teams.exe to consider the machine as a VDI and starts the installation.
The RunInstalledExecutable has the sequence number 6598 and it’s higher than WriteRegistryValues which has 5000. This means that the installation starts after MSI registry in written on the machine, which allows us to create the above mentioned registry into the MSI.
Unfortunately, the installer places a desktop shortcut and a run key in registry, which allows Teams to start at every reboot/log on of the user.
In order to delete those, a custom action can be created in the MSI which deletes the desired entries. The vbscript code for this is:
set WshShell = CreateObject(“WScript.Shell”)
Set ObjShell= CreateObject(“Scripting.FileSystemObject”)
Set oReg = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv”)
If ObjShell.FileExists(WshShell.ExpandEnvironmentStrings(“%PUBLIC%”) & “\Desktop\Microsoft Teams.lnk”)
Then ObjShell.DeleteFile WshShell.ExpandEnvironmentStrings(“%PUBLIC%”) & “\Desktop\Microsoft Teams.lnk”
End If
oReg.DeleteValue HKLM,”SOFTWARE\Microsoft\Windows\CurrentVersion\Run\”,”Teams”
All other changes like Add/Remove programs name, icon can be customized in the MSI as desired.