Skip to content

Instantly share code, notes, and snippets.

@rohan-molloy
Created August 15, 2022 09:24
Show Gist options
  • Save rohan-molloy/0d73d68155270f4bbe5e2f78354891cc to your computer and use it in GitHub Desktop.
Save rohan-molloy/0d73d68155270f4bbe5e2f78354891cc to your computer and use it in GitHub Desktop.
How to stop teams starting at logon

Disable Teams Autostart

  1. Create the file C:\Windows\System32\GroupPolicy\User\Scripts\Logon\disableteams.cmd with the following contents
%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -File %WINDIR%\System32\GroupPolicy\User\Scripts\Logon\disableteams.ps1
  1. Create the file C:\Windows\System32\GroupPolicy\User\Scripts\Logon\disableteams.ps1 with the following contents
$entry = $null -eq (Get-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Run)."com.squirrel.Teams.Teams"
if ( !$entry ) {
Remove-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Run -Name "com.squirrel.Teams.Teams"
}
# Define Teams configuratin file path
$Teams_config_file = "$env:APPDATA\Microsoft\Teams\desktop-config.json"
$configs = Get-Content $Teams_config_file -Raw
# If Teams already doesn't auto-start, break out the script.
if ( $configs -match "openAtLogin`":false") {
break
}
# If Teams already ran, and set to auto-start, change it to disable auto-start
elseif ( $configs -match "openAtLogin`":true" ) {
$configs = $configs -replace "`"openAtLogin`":true","`"openAtLogin`":false"
}
# If it's a fresh file, add configuration to the end
else {
$disable_auto_start = ",`"appPreferenceSettings`":{`"openAtLogin`":false}}"
$configs = $configs -replace "}$",$disable_auto_start
}
# Overwritten the configuration with new values.
$configs | Set-Content $Teams_config_file
  1. Open gpedit.msc and navigate to User Configuration/Windows Settings/Scripts (Logon/Logoff)/Logon and add the script C:\Windows\System32\GroupPolicy\User\Scripts\Logon\disableteams.cmd
  2. Log off and back on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment