How to Fix: Gracefully Close Thunderbird using Batch Script
Infopackets Reader Steve T. writes:
" Dear Dennis,
I am trying to backup my Mozilla Thunderbird emails using an automated backup schedule. The problem is that Thunderbird is always running on my computer and there does not seem to be a way to gracefully close the program so that the backup can start. Without closing the Thunderbird before the backup, I run the risk of having corrupt backups due to files being in use. Can you please tell me if there is a way that I can gracefully close Thunderbird (without terminating the process unexpectedly) so that I can complete my automated backups? "
My response:
I had to do a bit of research on this and the answer is that there isn't a way to gracefully close Thunderbird - at least not using a command line parameter, for example. That said, after some stumbling around I've come up with some insight.
The Windows command "taskkill /im" by default will attempt to gracefully close a process whenever possible. Based on my experience this will close Thunderbird windows (such as a new composition, for example), but does not close the parent Thunderbird process.
To get the parent Thunderbird process to close, you will need to execute the "taskkill /im" command the number of times for each open Thunderbird window (for example: a new composition), followed by "taskkill /f /im" to kill the parent process. This should essentially gracefully close Thunderbird.
At this time I do not know of a way to count the number of open Thunderbird windows (as "tasklist" only shows 1 actively running task even if there are 10 open windows); as such, using a "for loop" with a finite number of "taskkill /im" should be able to get the job done.
How to Fix: Gracefully Close Thunderbird using Batch Script
You can use the following batch script to gracefully close 10 Thunderbird windows, then forcefully close it:
@echo off
for /l %%x in (1, 1, 10) do (
rem echo Loop iteration count %%x
taskkill /im thunderbird.exe
)
taskkill /f /im thunderbird.exe
If not using a batch file (such as outputting the above code directly the command line), don't use double percentage marks, otherwise the for loop won't work.
I hope that helps.
Got a Computer Question or Problem? Ask Dennis!
I need more computer questions. If you have a computer question -- or even a computer problem that needs fixing -- please email me with your question so that I can write more articles like this one. I can't promise I'll respond to all the messages I receive (depending on the volume), but I'll do my best.
About the author: Dennis Faas is the owner and operator of Infopackets.com. With over 30 years of computing experience, Dennis' areas of expertise are a broad range and include PC hardware, Microsoft Windows, Linux, network administration, and virtualization. Dennis holds a Bachelors degree in Computer Science (1999) and has authored 6 books on the topics of MS Windows and PC Security. If you like the advice you received on this page, please up-vote / Like this page and share it with friends. For technical support inquiries, Dennis can be reached via Live chat online this site using the Zopim Chat service (currently located at the bottom left of the screen); optionally, you can contact Dennis through the website contact form.
Most popular articles
- Which Processor is Better: Intel or AMD? - Explained
- How to Prevent Ransomware in 2018 - 10 Steps
- 5 Best Anti Ransomware Software Free
- How to Fix: Computer / Network Infected with Ransomware (10 Steps)
- How to Fix: Your Computer is Infected, Call This Number (Scam)
- Scammed by Informatico Experts? Here's What to Do
- Scammed by Smart PC Experts? Here's What to Do
- Scammed by Right PC Experts? Here's What to Do
- Scammed by PC / Web Network Experts? Here's What to Do
- How to Fix: Windows Update Won't Update
- Explained: Do I need a VPN? Are VPNs Safe for Online Banking?
- Explained: VPN vs Proxy; What's the Difference?
- Explained: Difference Between VPN Server and VPN (Service)
- Forgot Password? How to: Reset Any Password: Windows Vista, 7, 8, 10
- How to: Use a Firewall to Block Full Screen Ads on Android
- Explained: Absolute Best way to Limit Data on Android
- Explained: Difference Between Dark Web, Deep Net, Darknet and More
- Explained: If I Reset Windows 10 will it Remove Malware?
My name is Dennis Faas and I am a senior systems administrator and IT technical analyst specializing in cyber crimes (sextortion / blackmail / tech support scams) with over 30 years experience; I also run this website! If you need technical assistance , I can help. Click here to email me now; optionally, you can review my resume here. You can also read how I can fix your computer over the Internet (also includes user reviews).
We are BBB Accredited
We are BBB accredited (A+ rating), celebrating 21 years of excellence! Click to view our rating on the BBB.