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?
- Download and install Microsoft Teams
- Download and install Node.JS
- Open the CMD prompt as an Administrator
- Run:
npm install -g asar
- 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. - Navigate to C:\Temp\asar\lib
- Locate desktopConfigurationManager.js and open the file with Notepad++
- Search for OPENATLOGIN (There should be two references) and set the value to FALSE as shown below in the screenshots:
- li>
Last but not least, it is time to repackage everything!
- 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
Ben Lye
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
Jose Espitia
Thanks Ben! I couldn’t figure out how to make it the exact size so this will be extremely helpful!
nicolai brink
error: unknown option `-u’ ?
Jose Espitia
Nicolai,
Did you use the following command?
asar pack “C:\TEMP\asar” “C:\TEMP\app.asar” –unpack *.node
Trev
It’s two dash’s (-‘s) for the switches. Looks like one with the font of the webpage.
Daniel
Hi, thanks, this command worked for me:
asar pack “C:\TEMP\asar” “C:\TEMP\app.asar” –-unpack {*.node,adal.dll} -–unpack-dir node_modules\slimcore\bin
Jose Espitia
Thanks Daniel!
Luke
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.
Joe
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.
Leo Boucher
We are also trying to stop Teams from launching when Window starts. I followed the instructions to create the app.asar file, but don’t know how to launch it from a script. I don’t know if this is a powershell script, or something else.
It also look like the script is meant to stop Teams from launching at startup, but it seems that the directory that the app.asar file is being copied to does not exist until Teams is installed and has launched once.
Am I missing someting?
Jose Espitia
Leo,
You just need to run the following Powershell script to install Teams and then copy the app.asar file the user’s local appdata directory:
# 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
During my testing, the application never auto launched but if it does; I would just exit the process after you copy the app.asar file.
srinath
did you try on windows 10? i tried the same but it shows up again.
Jose Espitia
Yes, we deployed Teams to Windows 10 with this method. Did you make sure that Teams was completely removed before reinstalling?
Mark
Getting an error running npm install -g asar.
C:\WINDOWS\system32>npm install -g asar
npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
npm ERR! errno SELF_SIGNED_CERT_IN_CHAIN
npm ERR! request to https://registry.npmjs.org/asar failed, reason: self signed certificate in certificate chain
npm ERR! A complete log of this run can be found in:
npm ERR!
Jose Espitia
Mark, do you have a proxy turned on? Also have you tried the solutions on this page:
https://blog.npmjs.org/post/78085451721/npms-self-signed-certificate-is-no-more
phil
hey thanks for this info. my second openatlogin statement isn’t the same as yours any suggestions?
else if (!this.config.overrideOpenAsHiddenProperty && utility.isWindows()) {
// Override openAsHidden value to false.
let appPrefs = {
‘openAtLogin’: this.config.appPreferenceSettings.openAtLogin,
Jose Espitia
Phil,
The screenshot is an example of what the end result should look like. Please modify the statement like this:
else if (!this.config.overrideOpenAsHiddenProperty && utility.isWindows()) {
// Override openAsHidden value to false.
let appPrefs = {
‘openAtLogin’: false,
Manuel Martinez
Hi Jose,
Thank you so much for your help. Although my second openAtLogin is different. I have:
class DesktopConfigurationManager {
constructor() {
this.defaultAppPrefs = {
‘openAtLogin’: utility.isMac() ? false : false,
// Note: openAsHidden feature is not enabled for Mac
‘openAsHidden’: false,
‘runningOnClose’: false,
‘registerAsIMProvider’: false
};
this.rigelAppPrefs = {
‘openAtLogin’: false,
‘openAsHidden’: false,
‘runningOnClose’: false,
‘registerAsIMProvider’: false
};
this.config = null;
this.loggingService = LoggingService.getInstance();
this.shouldSave = false;
this.load();
this.logConfigJson(‘Initialization completed. Loaded config = ‘, this.config);
this.getOrCreateMachineId();
this.setPreviousWebClientVersionInLoggingService();
this.setAppVersions();
// Don’t run in UTs
if (!process.tests) {
utility.setIntervalWithBackoff(() => { return this.saveTask(); }, 5 * constants.timeInMiliseconds.second, (n) => utility.exponentialFunc(n, constants.timeInMiliseconds.hour));
}
processEnv_1.default.previousAppLaunchTime = this.config.launchTime;
}
Could you please let me know, what should I do?
Thank in advance
Jose Espitia
Hi Manuel,
Both openAtLogin should look like this:
‘openAtLogin’: false,
Jimmy Dean
Hello Jose! I wanted to ask you if this works for Terminal servers? We want to disable the startup of teams for ALL users. Not sure if this method would work in this situation?
Thank you!
Jose Espitia
Hi Jimmy,
I don’t see why it wouldn’t work. You’re modifying the source code of the application to disable automatic startup so it should work on any system.