Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
For running multiple MS Teams accounts side by side. Save this with the name of the MS Teams profile you wish to use. When launched, a folder will be created in your user profile. See https://danielsmon.com/2020/04/02/multiple-ms-teams-accounts-on-the-desktop/.
@ECHO OFF
REM Uses the file name as the profile name
SET MSTEAMS_PROFILE=%~n0
ECHO - Using profile "%MSTEAMS_PROFILE%"
SET "OLD_USERPROFILE=%USERPROFILE%"
SET "USERPROFILE=%LOCALAPPDATA%\Microsoft\Teams\CustomProfiles\%MSTEAMS_PROFILE%"
REM Ensure there is a downloads folder to avoid error described at
REM https://gist.github.com/DanielSmon/cc3fa072857f0272257a5fd451768c3a
mkdir "%LOCALAPPDATA%\Microsoft\Teams\CustomProfiles\%MSTEAMS_PROFILE%\Downloads"
ECHO - Launching MS Teams with profile %MSTEAMS_PROFILE%
cd "%OLD_USERPROFILE%\AppData\Local\Microsoft\Teams"
"%OLD_USERPROFILE%\AppData\Local\Microsoft\Teams\Update.exe" --processStart "Teams.exe"
@mkoertgen
Copy link

mkoertgen commented Jun 4, 2020

I understand that electron apps like Teams are user-profile-specific. So this is a very simple and effective hack.
Many thanks! Has been a lifesaver for me!

Loading

@frankhommers
Copy link

frankhommers commented Aug 31, 2020

Awesome! I use this on my Windows machine.

I need something like this for MacOS as well.... Any pointers?

Loading

@MayakoAelys
Copy link

MayakoAelys commented Sep 16, 2020

Fantastic! Thanks a lot.

Loading

@gidifede
Copy link

gidifede commented Nov 4, 2020

Can we use the trick to have at the same time

  • one instance of teams opened with the profile of my organization (myprofile@orgA.com)
  • one instance of teams opened with the profile of another organization (myprofile@orgB.com), not sure if a profile of the org B can be created on a machine joined in org A

Loading

@MayakoAelys
Copy link

MayakoAelys commented Nov 4, 2020

@gidifede yes, this is what I'm doing everyday: I open my computer and start Teams as usual through the Start Menu. Then I launch my second Teams using this script, connected to my other tenant.

What's tricky is that the default Teams app will be the one launched without the script, it means that if you click on a Teams meeting link, it is the default app that will be launched. You need to keep that in mind or you'll face some surprises.

Loading

@chudson121
Copy link

chudson121 commented Mar 3, 2021

this is awesome Thanks!!!

Loading

@dariobauer
Copy link

dariobauer commented May 13, 2021

This cmd was working perfectly for me and my colleagues but recently we have been getting the following JavaScript error. I assume that either the OS or Teams was updated by our corporate IT.

Error: Failed to get 'downloads path
at Object.<anonymous> (C:\Users\[username]\AppData\Local\Microsoft\Teams\current\resources\app.asar\lib\loca...:54)
at Module.compile (C:\Users\[username]\AppData\Local\Microsoft\Teams\current\resources\app.asar\externa...:36)
at Object.Module.extensions..js (internal/modules/cjs/loader.js:986:10)
at Module.load (internal/modules/cjs/loader.js:816:32)
at Function.Module._load (electron/js2c/asar.js:748:26)
at Module.require (internal/modules/cjs/loader.js:853:19)
at require (C:\Users\[username]\AppData\Local\Microsoft\Teams\current\resources\app.asar\externa...:28)
at Object.<anonymous> (C:\Users\[username]\AppData\Local\Microsoft\Teams\current\resources\app.asar\lib\loca...:20)
at Module.compile (C:\Users\[username]\AppData\Local\Microsoft\Teams\current\resources\app.asar\externa...:36)

Any ideas on a cause or fix?

Loading

@mkoertgen
Copy link

mkoertgen commented May 14, 2021

Jup, this hit me too. Sadly not working anymore.

Loading

@xLAva
Copy link

xLAva commented May 17, 2021

There is a workaround - create a "Downloads" folder in
%LOCALAPPDATA%\Microsoft\Teams\CustomProfiles\%MSTEAMS_PROFILE%\

Loading

@DanielSmon
Copy link
Author

DanielSmon commented May 17, 2021

There is a workaround - create a "Downloads" folder in
%LOCALAPPDATA%\Microsoft\Teams\CustomProfiles\%MSTEAMS_PROFILE%\

Thanks @xLAva, since this was reported I've now also started experiencing this issue. Creating the downloads folder fixed it for me too. I've now added a mkdir command on line 12 to take care of this in the main script. Cheers!

Loading

@dfbaskin
Copy link

dfbaskin commented Jun 9, 2021

For what it's worth, here's the same script in Powershell:

$profileName = [io.path]::GetFileNameWithoutExtension($PSCommandPath)
Write-Output "Launching $profileName Teams Profile ..."

$userProfile = $env:USERPROFILE
$appDataPath = $env:LOCALAPPDATA
$customProfile = "$appDataPath\Microsoft\Teams\CustomProfiles\$profileName"
$downloadPath = Join-Path $customProfile "Downloads"

if (!(Test-Path -PathType Container $downloadPath)) {
  New-Item $downloadPath -ItemType Directory |
    Select-Object -ExpandProperty FullName
}

$env:USERPROFILE = $customProfile
Start-Process `
  -FilePath "$appDataPath\Microsoft\Teams\Update.exe" `
  -ArgumentList '--processStart "Teams.exe"' `
  -WorkingDirectory "$appDataPath\Microsoft\Teams"

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment