How to disable Microsoft Teams from running at logon

If you landed on this page you are probablly working on packaging Microsoft Teams and have been banging your head against a desk trying to figure out how to disable it from loading at startup. Fortunately for you, I figured out a solution that works 100% of the time.

What do you need?
Node.JS
Microsoft Teams
Notepad++

Where to download?
Node.JS – https://nodejs.org/en/
Microsoft Teams – https://teams.microsoft.com/downloads
Notepad++ – https://notepad-plus-plus.org/

Brief background
Essentially, Microsoft Teams is a webpage in the background. It was developed with Electron which is a framework that lets developers create cross-platform desktop apps with web front-end technologies. Some other popular applications such as Skype, and Visual Studio Code were also built with using this technology.

With Electron apps, most of the source files for the application will be packaged into a file named app.asar. You can open the file in Notepad but you cannot save it since it is a READONLY file. From my experience, any changes made to it via Notepad will crash the app and prevent it from loading.

How do you do it?

  1. Download and install Microsoft Teams
  2. Download and install Node.JS
  3. Open the CMD prompt as an Administrator
  4. Run: npm install -g asar
  5. Run: asar extract "%LOCALAPPDATA%\Microsoft\Teams\current\resources\app.asar" C:\Temp\asar
    Note – Try running “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Node.js\Node.js command prompt.lnk” if the command prompt does not recognize the ASAR command.
  6. Navigate to C:\Temp\asar\lib
  7. Locate desktopConfigurationManager.js and open the file with Notepad++
  8. Search for OPENATLOGIN (There should be two references) and set the value to FALSE as shown below in the screenshots:
    disable teams at startup
    disable teams at startupli>

    Last but not least, it is time to repackage everything!

  9. Run: asar pack "C:\TEMP\asar" "C:\TEMP\app.asar" --unpack *.node

Now that you have a customized app.asar, you can silently install Teams and also not worry about it launching at startup. See the install script below for an example:

# Install Microsoft Teams
Start-Process "$PSScriptRoot\Teams_windows_x64.exe" -ArgumentList "-s" -Wait

# Copy customized app.asar
Copy "$PSScriptRoot\app.asar" "$env:LOCALAPPDATA\Microsoft\Teams\current\resources\app.asar" -Force

8 Comments

  1. Nice tip. I noticed that the re-packed app.asar was quite a lot larger than the original. In order to pack a new app.asar file which was identical except for the preference change I used this command:

    asar pack “C:\TEMP\asar” “C:\TEMP\app.asar” –unpack {*.node,adal.dll} –unpack-dir node_modules\slimcore\bin

  2. I found another way of stopping teams from running on first login… use group policy (run once) or a login script to create an empty folder called “Teams” in “%userprofile%\AppData\Local\Microsoft\” this will prevent the installer from running on first login.
    for users who then wish to use teams give them a script that will delete this empty folder allowing the installer to run on next login.

    • Jose Espitia

      Luke, I’m not trying to prevent the install from running for users. I am just trying to disable the auto-start application setting by default during the install.

  3. I’m guessing this would be have to be re-done with each update? Teams auto-updates doesn’t it? Once a month? https://support.office.com/en-gb/article/what-s-new-in-microsoft-teams-d7092a6d-c896-424c-b362-a472d5f105de?ui=en-US&rs=en-GB&ad=GB

    • Jose Espitia

      Joe, It shouldn’t be an issue if the user has already launched the application. By that time, the setting should be stored in the user’s profile so it doesn’t need to be reconfigured.

Leave a Reply