Start Thunderbird, sync and quit from the command line

User Help for Mozilla Thunderbird
Posts: 128
Joined: November 25th, 2003, 8:56 am

Post Posted November 14th, 2019, 12:48 pm

I want to be able to script Thunderbird starting up, syncing email and then quitting. I want it to happen overnight when I'm not using the computer via Task Scheduler, basically as a backup of an IMAP account.

Is there a way to do it?


User avatar
Posts: 46341
Joined: July 30th, 2003, 5:06 pm

Post Posted November 14th, 2019, 2:45 pm

The problem is automating Thunderbird quitting

See ... scheduler/ . The Advanced Task Settings section talks about how to modify the tasks properties to end the task after a fixed amount of time. ... windows-10 is a similar writeup. However, I suspect it doesn't give you fine enough control over how long the task runs, and you would be better off writing a short PowerShell script to launch Thunderbird, and have the task scheduler run that PowerScript. ... ll-scripts talks about how to create a time out in PowerShell scripts. Later on you might find a cleaner/better way to shutdown Thunderbird. I suspect you will need to have the PowerShell script delete the parent.lock temporary file created by Thunderbird in its profile, after it stops Thunderbird. Otherwise you might have problems when you manually launch Thunderbird later on and it checks for the existence of that file, finds it and refuses to launch as it thinks another instance is still running. ... owershell/ ... ons-guide/ ... -execution

One alternative might be to have the task scheduler launch Thunderbird and then a couple of minutes later have another task run a AudoIt or AutoHotKey script to cleanly exit Thunderbird (it could select file -> exit). That would avoid you having to learn PowerShell.

When you get something working please post a writeup of what you did to help somebody else who might want to do the same thing.

Posts: 128
Joined: November 25th, 2003, 8:56 am

Post Posted November 14th, 2019, 2:54 pm

Thanks, that's a good idea. If I just let it run for several hours overnight it should sync.

Posts: 3682
Joined: February 3rd, 2009, 6:29 pm

Post Posted November 14th, 2019, 3:26 pm

You can politely close the thunderbird.exe process with NirCmd closeprocess.


More info: viewtopic.php?p=14166149#p14166149

nsICommandLineHandler example

In Thunderbird 68...

* create manifest.json file
* replace XPCOMUtils.generateQI with ChromeUtils.generateQI in commandline.js file
* replace MailOfflineMgr.toggleOfflineStatus with goQuitApplication in commandline.js file

More info

Return to Thunderbird Support

Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests