More Notes on Teams

Quick shoutout to this excellent blog post by James Rankin on installing Teams (aptly titled installing the damned thing).

A few weeks ago I had blogged about Teams and I thought I had it under control. Since then however, I realized whenever users login to my Citrix session servers Teams always launches even though I had OPTIONS="noAutoStart=true" set as part of the installer. Moreover, I also had the GPO from Microsoft set – Prevent Microsoft Teams from starting automatically after installation – but looks like it was being ignored?

Googling on this there’s a whole load of conflicting info. Apparently the GPO only kicks in if you applied it before a user has logged in. Once the user has logged in the GPO doesn’t matter (seriously, wtf?!) Never mind, there are workarounds like modifying the desktop-config.json in each user’s AppData Roaming folder via a startup PowerShell script (hah! nuts) and manipulate a setting there (example scripts here, here, and here). Even though I hate the idea I tried it… but that too doesn’t work. I quit Teams, make the change, logout and login and bam! Teams is back.

Why doesn’t Teams just use a registry key or be controllable via a GPO? I mean you can control some aspects like disabling fallback mode in VDI via an HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Teams\DisableFallback or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Teams\DisableFallback registry key, so it’s not too much of an ask. Modifying settings via startup scripts that tweak a JSON file is so 1990s (and yet 2020s coz we use PowerShell). Weird!

I spent a couple of days thinking if it was Citrix or something wrong in my environment. Then I remembered there’s an HKLM key that Teams sets as part of its install. The Teams installers creates HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Run which is what injects Teams into each user’s profile and sets up an entry under their HKCU to update and launch Teams subsequently.

According to the Citrix docs these can be in three places:

  • HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  • HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

In my case it was the first one and so I deleted that to stop it was auto launching at startup.

While Googling on that registry key though to see if anyone else has encountered this (coz at this point I was feeling pretty stupid since none of the “standard” ways seemed to work for me, and deleting the registry key felt like a hack) and that’s when I came across James’s funny post. That gave me a chuckle!

From there I learnt the following caveat to my approach though:

So can we just delete the HKLM entry and have done with it that way?

Well, yes, but with a significant caveat. The problem is that once auto-setup has been run, on subsequent logons, the auto-launch (so not the first-time setup, but the automatic launch of Teams for a user who has already done the auto-setup step, which we will refer to as auto-launch from hereon in) is also driven by the HKLM Registry value. So if you delete the HKLM Registry value so that users trigger the auto-setup step themselves, then the users will have to remember to manually launch Teams every time they log in. This isn’t ideal – apps like Teams are good to get auto-launched, because otherwise users may miss important conversations and messages. And don’t forget – there is no option in the user interface to auto-start Teams with the Machine-Wide Installer. The “user” version of Teams (the one that auto-updates, which we don’t want to use) has the option to auto-start in the GUI…

Bugger. The last point is even more irritating with the Machine-Wide Installer – as he said, there’s no way users can enable Teams to auto-start. Really, Teams is one of the worstly designed products for admin deployment and management!

On a side note I learnt from James’s blog post that in his experience too the GPO and those desktop-config.json settings did zilch! So at least I wasn’t being stupid.

Continuing with James’s post here’s what he felt one requires of Teams:

Now, our requirements appear to be thus – we want to disable the auto-setup, so that new users don’t all launch Teams at once and hammer the system resources, but once they have launched Teams for the first time, we want the program to auto-launch so they don’t have to run it manually.

… as well as getting rid of the auto-setup but keeping the auto-launch, we also want to force Teams to actually honour the setting for openAsHidden from the GUI.

You should obviously go read his much better blog post than mine, but here’s what we need to do more as a reference to myself.

Step 1: Delete the HKLM registry key as I mentioned above. Either make it a part of your installation (my PSADT script does this) or use Group Policy Preferences:

(The first entry is to stop Teams from failing back to the Citrix server if the user is connected from a non Teams optimized Citrix endpoint).

Step 2: When Teams opens let it do so hidden. This is actually tweaked by the desktop-config.json file(!!) so a PowerShell startup script is in order.

Here’s the one I am going to use, but there’s loads more if you Google for it. Need to push this out as a user logon script.

Step 3: We want Teams to launch if a user has already launched it once. This is important – by deleting the HKLM key above we are ensuring it doesn’t just launch for everyone, but once you have launched it manually then we want it to always start (and be hidden – that’s set by the desktop-config.json file above, but Teams ignores that so we need to cater for that too – aaargh!).

Here’s what James does for that: if a user has launched Teams then the desktop-config.json file would be present. So he checks for that file and if it exists adds an HKCU\Software\Microsoft\Windows\CurrentVersion\Run entry to launch Teams. This points to the following:

This is same as what the HKLM entry used to point to, but with an additional switch which is required to make it honour the desktop-config.json file.

[ Update (the next day): This doesn’t work! Teams seems to still ignore desktop-config.json. 🤷🏼‍♂️I hate this product! As of now I’ve decided to just disable auto-launch and users can launch Teams manually. No one launches Outlook or Word automatically anyways, so I am going to deal with Teams similarly. So step 2 does not work, and I’ve decided not to do step 3 below.]

Next, he goes ahead and deletes the same HKCU\Software\Microsoft\Windows\CurrentVersion\Run entry if this desktop-config.json file is not present. This is just a continuation of the two HKLM entries I deleted in step 1 and he’s being complete I think by also taking care of the HKCU case (Citrix too points to this, so its a good thing he’s doing it). If the desktop-config.json file is not present it means the user hasn’t run Teams yet so don’t bother launching it.

XML version in case it helps copy-paste:

So that’s where I am at today. Will update this post with more info if there’s any.