none
Minimize Teams to system tray after installation and login RRS feed

  • Question

  • I was curious if there was a reg key or file we can change to allow Microsoft Teams to just automatically launch to the system tray instead of on the desktop at windows login.  I think it would be great if possible like we do with Skype for Business.  

    Thanks,

    Mike

    Thursday, April 19, 2018 3:43 AM

Answers

  • Teams does not use reg settings, so unfortunately no. The only way is to set the "Open application in background" option in the client itself. It *should* be stored somewhere in the %APPDATA%\Roaming\Microsoft\Teams\desktop-config.json file, so you can just overwrite that. I believe it's the appPreferenceSettings element:

    "appPreferenceSettings":{"openAsHidden":true,"openAtLogin":false,"runningOnClose":true}

    Thursday, April 19, 2018 7:57 AM

All replies

  • Teams does not use reg settings, so unfortunately no. The only way is to set the "Open application in background" option in the client itself. It *should* be stored somewhere in the %APPDATA%\Roaming\Microsoft\Teams\desktop-config.json file, so you can just overwrite that. I believe it's the appPreferenceSettings element:

    "appPreferenceSettings":{"openAsHidden":true,"openAtLogin":false,"runningOnClose":true}

    Thursday, April 19, 2018 7:57 AM
  • Are you saying if I set this this will open the application in the "background" which will feel like its minimized to the system tray?  Or is it just going to launch it full screen on startup?

    OpenAsHidden:true I see.  That might do it

    Thanks for the help


    Friday, April 20, 2018 7:02 PM
  • Yup, openAsHidden should be the option that controls this, the part I'm not certain about is whether you can edit the settings file outside of Teams and not cause issues.
    Friday, April 20, 2018 8:21 PM
  • Thanks for everyones help we circled back around to this and just ended up creating a simple powershell script and leveraged an SCCM configuration baseline to evaluate the json file for OpenAsHidden:False and flip that if it ever changed. 

    Reason why we went with a Configuration Item is we were worried with future releases the json file would be updated or changed.  This now keeps it in place until there is a better way to do it.

    Thanks again

    Thursday, September 6, 2018 7:29 PM
  • Hi Good to know you have the solution now could you please Share your script wit us. Thanks in advance.
    Sunday, November 11, 2018 8:35 PM
  • Right clicking on the Task Bar or Tray icon allows you to simply open the settings menu. Which contains this option.Open application in background
    Wednesday, November 21, 2018 8:49 AM
  • Thanks Webbes, yes that setting does the exact same the .json file does. But I'd like to automate it for deployment. Currently, I'm using a DCM rule in ConfigMgr to watch that .json file and set it to hidden. Works pretty well.
    Wednesday, November 21, 2018 3:45 PM
  • Sure,

    Here is the discovery script:

    #$LOCALDATA = $env:LOCALAPPDATA
    $UserAppDateRoaming = (Get-Childitem Env:APPDATA).value
    $TeamsDesktopConfigJSONFile = "Microsoft\Teams\desktop-config.json"
    $TeamsPathDesktopConfigJSONFile = "$UserAppDateRoaming\$TeamsDesktopConfigJSONFile"
    If (Test-Path $TeamsPathDesktopConfigJSONFile) {
        #Write-Host "File Exists"
        #Copy-Item $TeamsPathDesktopConfigJSONFile -destination "$TeamsPathDesktopConfigJSONFile.org"
        $a = Get-Content $TeamsPathDesktopConfigJSONFile -raw | ConvertFrom-Json
        #$a.appPreferenceSettings.openAsHidden = $true
        #$a | ConvertTo-Json -depth 20 | set-content $TeamsPathDesktopConfigJSONFile
        If ($a.appPreferenceSettings.openAsHidden -eq $false) {
            Return $False
            }
        Else {
            Return $True
            }
    }
    Else {
        Return $True 
        }

    And here is the remediation script:

    #Make sure Teams is closed
    $Teams = Get-Process Teams -ErrorAction SilentlyContinue
    if ($Teams) {
      #Try Gracefully closing
      $Teams.CloseMainWindow()
      Sleep 10 
      Stop-Process -Name "Teams" -Force
    }
    
    #Inject OpenasHiddenTrue into JSON File
    #$LOCALDATA = $env:LOCALAPPDATA
    $UserAppDateRoaming = (Get-Childitem Env:APPDATA).value
    $TeamsDesktopConfigJSONFile = "Microsoft\Teams\desktop-config.json"
    $TeamsPathDesktopConfigJSONFile = "$UserAppDateRoaming\$TeamsDesktopConfigJSONFile"
    If (Test-Path $TeamsPathDesktopConfigJSONFile) {
        #Write-Host "File Exists"
        Copy-Item $TeamsPathDesktopConfigJSONFile -destination "$TeamsPathDesktopConfigJSONFile.org"
        $a = Get-Content $TeamsPathDesktopConfigJSONFile -raw | ConvertFrom-Json
        If ($a.appPreferenceSettings.openAsHidden -eq $false) {
            $a.appPreferenceSettings.openAsHidden = $true
            $a | ConvertTo-Json -depth 20 | set-content $TeamsPathDesktopConfigJSONFile
            }
    
    If using the Configuration Item in ConfigMgr, make sure to set the script to 'Run scripts by using the logged on user credentials' 

    Hope this helps.


    • Edited by Mike Snodgrass Wednesday, November 21, 2018 5:59 PM
    • Proposed as answer by Fedor T Saturday, March 21, 2020 3:28 PM
    Wednesday, November 21, 2018 3:51 PM
  • Thanks for this thread guys.

    Seems crazy they haven't thought about this.

    I see MS has now added a GPO for not starting on first installation ... hopefully eventually they can put background start in the same place. :/

    Mike, yours is the only possible solution I've found to date, so ta for that ... I'll have an experiment and see if it's viable in our environment.

    I'm a bit confused as to why this is split into two scripts rather than one though? Maybe I'll find out when I try it ...

    Tuesday, July 16, 2019 11:36 AM
  • We did it this way because we used a Configuration item and baseline in ConfigMgr to stay compliant in case this file would be updated or changed. You can combine or just deploy the 2nd script using other deployment tools but this keeps us always remediated (compliant) in case the file changes. Hope this helps clarify



    Tuesday, July 16, 2019 2:11 PM
  • Thanks Mike, and cheers for getting back so quickly. :)

    I'm gunna have to find another way to run the script (probably as a GPO login script), but good to know why you did it like that and that there's no reason not to combine.

    Cheers,

    Ben.

    Tuesday, July 16, 2019 2:22 PM
  • Just for convenience, this is Mike's combined script, tested and works. Still need to work out how to apply it with the right Win 10 permissions, but that's a different issue.

    Cheers again Mike.

    $UserAppDateRoaming = (Get-Childitem Env:APPDATA).value
    $TeamsDesktopConfigJSONFile = "Microsoft\Teams\desktop-config.json"
    $TeamsPathDesktopConfigJSONFile = "$UserAppDateRoaming\$TeamsDesktopConfigJSONFile"
    
    If (Test-Path $TeamsPathDesktopConfigJSONFile) {
    	$a = Get-Content $TeamsPathDesktopConfigJSONFile -raw | ConvertFrom-Json
    	If ($a.appPreferenceSettings.openAsHidden -eq $false) {
            	Write-Host "Settings Need Changing"
            	#Make sure Teams is closed
    		$Teams = Get-Process Teams -ErrorAction SilentlyContinue
    		If ($Teams) {
      			#Try Gracefully closing
      			$Teams.CloseMainWindow()
      			Sleep 10 
      			Stop-Process -Name "Teams" -Force
    		}
    		#Inject OpenasHiddenTrue into JSON File
    		$UserAppDateRoaming = (Get-Childitem Env:APPDATA).value
    		$TeamsDesktopConfigJSONFile = "Microsoft\Teams\desktop-config.json"
    		$TeamsPathDesktopConfigJSONFile = "$UserAppDateRoaming\$TeamsDesktopConfigJSONFile"
    		If (Test-Path $TeamsPathDesktopConfigJSONFile) {
    			Write-Host "File Exists"
    			Copy-Item $TeamsPathDesktopConfigJSONFile -destination "$TeamsPathDesktopConfigJSONFile.org"
    			$a = Get-Content $TeamsPathDesktopConfigJSONFile -raw | ConvertFrom-Json
    			If ($a.appPreferenceSettings.openAsHidden -eq $false) {
    				$a.appPreferenceSettings.openAsHidden = $true
    				$a | ConvertTo-Json -depth 20 | set-content $TeamsPathDesktopConfigJSONFile
    			}
    		}
    	}
    }   

     

     







    • Edited by benweston Wednesday, July 17, 2019 4:43 PM
    Wednesday, July 17, 2019 4:28 PM
  • Glad I could help, you could also have it re-open Teams after the file is modified. We currently do not do that but may change it when we deprecate the Skype for Business client and switch to full Teams.  Also my apologies I left a lot of leftover testing junk (Stuff with # in front) when I pasted that script the first time!
    Wednesday, July 17, 2019 4:31 PM
  • Hah, yes, ta only just noticed the junk ... I've removed most of it from my script above now. :)

    Did think about restarting Teams, although I've seen a few times it goes 'Something Went Wrong' if it's opened immediately after this script (no obvious reason), so tbh I'm happy for people to wait for next login.

    What I will probably add to ours is the setting to always autostart, as we don't want certain people turning that off here, but that looks fairly trivial to add in the format of your script.

    Cheers dude.

    Ben. 

    Wednesday, July 17, 2019 4:48 PM
  • Below is another version of Mike's script, this time also forcing the status of "openAtLogin" to true as well as "openAsHidden". This is for environments/areas where you don't want people choosing to have it never run, even minimized.

    Update - I was able to run this cleanly as a GPO Powershell Logon Script. For anyone else who hasn't needed to run a GPO Powershell script for years, there's a seperate tab now for Powershell, and it happily bypasses all the Windows 10 execution lockdown without any any extra fuss.

    So we now have everything running as we'd like it automatically.

    The only outstanding issue is that the very first time someone uses a new PC (new local profile), it still wants signing in once regardless of any of these roaming settings - but we can live with that for now (we could use the new GPO setting to allow people to initate their own use of Teams on each PC, but in our place that'd just mean nobody used it).

    Cheers,

    Ben.

    $UserAppDateRoaming = (Get-Childitem Env:APPDATA).value
    $TeamsDesktopConfigJSONFile = "Microsoft\Teams\desktop-config.json"
    $TeamsPathDesktopConfigJSONFile = "$UserAppDateRoaming\$TeamsDesktopConfigJSONFile"
    
    If (Test-Path $TeamsPathDesktopConfigJSONFile) {
        Write-Host "File Exists"
    	$a = Get-Content $TeamsPathDesktopConfigJSONFile -raw | ConvertFrom-Json
    	If (($a.appPreferenceSettings.openAsHidden -eq $false) -Or ($a.appPreferenceSettings.openAtLogin -eq $false)) {
            	Write-Host "Settings Need Changing"
            	#Make sure Teams is closed
    		$Teams = Get-Process Teams -ErrorAction SilentlyContinue
    		If ($Teams) {
      			#Try Gracefully closing
      			$Teams.CloseMainWindow()
      			Sleep 10 
      			Stop-Process -Name "Teams" -Force
    		}
    		#Inject openAsHidden True and openATLogin True into JSON File
    		$UserAppDateRoaming = (Get-Childitem Env:APPDATA).value
    		$TeamsDesktopConfigJSONFile = "Microsoft\Teams\desktop-config.json"
    		$TeamsPathDesktopConfigJSONFile = "$UserAppDateRoaming\$TeamsDesktopConfigJSONFile"
    		If (Test-Path $TeamsPathDesktopConfigJSONFile) {
    			Write-Host "File Exists"
    			Copy-Item $TeamsPathDesktopConfigJSONFile -destination "$TeamsPathDesktopConfigJSONFile.org"
    			$a = Get-Content $TeamsPathDesktopConfigJSONFile -raw | ConvertFrom-Json
    			If (($a.appPreferenceSettings.openAsHidden -eq $false) -Or ($a.appPreferenceSettings.openAtLogin -eq $false)) {
    				$a.appPreferenceSettings.openAsHidden = $true
    				$a.appPreferenceSettings.openAtLogin = $true
    				$a | ConvertTo-Json -depth 20 | set-content $TeamsPathDesktopConfigJSONFile
    			}
    		}
    	}
    }   






    • Edited by benweston Thursday, July 18, 2019 2:24 PM
    Thursday, July 18, 2019 9:09 AM
  • "The only outstanding issue is that the very first time someone uses a new PC (new local profile), it still wants signing in once regardless of any of these roaming settings"

    I've now realised this was partly due to our excluding too much of the Teams folder from the Roaming Profile via GPO.

    We're now just excluding AppData\Roaming\Microsoft\Teams\Application Cache and AppData\Roaming\Microsoft\Teams\Cache, which seem to hold the bulk of the unnecesary Roaming size (we'll keep an eye on this to see if any other sub-folders bloat).

    Set like this, Teams still "opens" unminimized once on each new PC (new local profile) creation, regardless of the minimize setting, but does automatically sign in again.



    • Edited by benweston Friday, July 19, 2019 9:00 AM
    Friday, July 19, 2019 8:56 AM
  • Another variation of Mike's script I've written is below, which now restarts Teams client (after fixing the settings in the same login instead of waiting for next login).

    It also forces an Explorer restart during the fix - this is just to remove the 'ghost' task bar icon which is left if you shutdown Teams with Powershell (it causes a screen flicker/icon refresh as a side-effect, but this will only happen when the settings repair is actually needed - but it has the bonus that it does allow you to notice if the repair is taking effect).

    I've also slightly tweaked some of the code, just for smoothness but not really affecting functionality.

    $UserAppDateRoaming = (Get-Childitem Env:APPDATA).value
    $TeamsDesktopConfigJSONFile = "Microsoft\Teams\desktop-config.json"
    $TeamsPathDesktopConfigJSONFile = "$UserAppDateRoaming\$TeamsDesktopConfigJSONFile"
    $TeamsStartPath = "$UserAppDateRoaming\Microsoft\Windows\Start Menu\Programs\Microsoft Corporation"
    
    If (Test-Path $TeamsPathDesktopConfigJSONFile) {
    	Write-Host "Settings File Exists"
    	$a = Get-Content $TeamsPathDesktopConfigJSONFile -raw | ConvertFrom-Json
    	If (($a.appPreferenceSettings.openAsHidden -eq $false) -Or ($a.appPreferenceSettings.openAtLogin -eq $false)) {
    		Write-Host "Settings Need Changing"
    		#Make sure Teams is closed
    		$Teams = Get-Process Teams -ErrorAction SilentlyContinue
    		If ($Teams) {
    			Write-Host "Stopping Teams"
      			#Close Teams Window
      			$Teams.CloseMainWindow()
    			Write-Host "Waiting 5s For Teams Window to Close"
    			Sleep 5
    			#Close Teams 
    			Stop-Process -Name "Teams" -Force
    			Write-Host "Waiting 5s For Teams to Close"
    			Sleep 5
    			#Refresh Explorer To Clean Up Ghost Taskbar Icons
    			Get-Process 'Explorer' | Stop-Process
    			Write-Host "Waiting 5s For Explorer to Refresh"
    			Sleep 5
    		}
    		#Inject openAsHidden True and openATLogin True into JSON File
    		$UserAppDateRoaming = (Get-Childitem Env:APPDATA).value
    		$TeamsDesktopConfigJSONFile = "Microsoft\Teams\desktop-config.json"
    		$TeamsPathDesktopConfigJSONFile = "$UserAppDateRoaming\$TeamsDesktopConfigJSONFile"
    		If (Test-Path $TeamsPathDesktopConfigJSONFile) {
    			Write-Host "Double-Checked File Exists, Changing Settings"
    			Copy-Item $TeamsPathDesktopConfigJSONFile -destination "$TeamsPathDesktopConfigJSONFile.org"
    			$a = Get-Content $TeamsPathDesktopConfigJSONFile -raw | ConvertFrom-Json
    			If (($a.appPreferenceSettings.openAsHidden -eq $false) -Or ($a.appPreferenceSettings.openAtLogin -eq $false)) {
    				$a.appPreferenceSettings.openAsHidden = $true
    				$a.appPreferenceSettings.openAtLogin = $true
    				$a | ConvertTo-Json -depth 20 | set-content $TeamsPathDesktopConfigJSONFile
    			}
    		}
    		$Teams = Get-Process Teams -ErrorAction SilentlyContinue
    		If (-Not $Teams) {
    		#Open Teams
    		Write-Host "Teams is Stopped - Starting Teams"
    		Start-Process -FilePath "$TeamsStartPath\Microsoft Teams"
    		}
    	} 
    	Else { 
    		Write-Host "Settings All Look Ok"
    	} 
    }





    • Edited by benweston Friday, September 13, 2019 2:44 PM
    Friday, September 13, 2019 2:41 PM
  • Well done Microsoft :(

    MCSE Mobility 2018. Expert on SCCM, Windows 10, ALOVPN, MBAM.

    Sunday, March 8, 2020 8:33 PM