6

Using the following line in a batch script to call thunderbird and compose an email:

thunderbird.exe -compose "to='email@domain.com',subject='Some Subject',preselectid='id1',body='Message Body',attachment='File.txt'"

The command performs perfectly fine, however the batch script will not continue until the application terminates. Is there a way to bypass this so that the script will continue on with the next command?

Anthony Miller
  • 15,101
  • 28
  • 69
  • 98
  • possible duplicate of [Invoke EXE from batch file *without* waiting](http://stackoverflow.com/questions/1648172/invoke-exe-from-batch-file-without-waiting) – CharlesB Jun 06 '11 at 15:06

1 Answers1

4

use start /b before the command, and the batch script will continue to execute after launching the process.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • Off-note: Is there a difference between running a program directly (e.g. CMD C:\Some\Program.exe) or with the START command with a /WAIT switch? – Anthony Miller Jun 06 '11 at 16:33
  • Doesn't the /b switch hide the application? "Start application without creating a new window"(via cmd START /?) – Anthony Miller Jun 06 '11 at 16:35
  • Good question, don't know the difference. `start` opens a console window which is not what you want, hence the `/b` flag – CharlesB Jun 06 '11 at 16:40
  • START /B works well for this. Just a note however, if you are referencing the absolute path (e.g. C:\Program Files\Mozilla Thunderbird\thunderbird.exe -compose "to='email@domain.com',subject='Some Subject',preselectid='id1',body='Message Body',attachment='File.txt'") It will fail because a path with spaces requires quotations, but the Thunderbird command line arguments requires quotations as well so you receive an error. Thanks Charles – Anthony Miller Jun 06 '11 at 17:55
  • @Mechaflash to avoid this you can CD into `C:\Program Files\Mozilla Thunderbird` before calling start, now without absolute path (nor quotes) since `thunderbird.exe` is in this directory – CharlesB Jun 06 '11 at 17:57
  • i believe thunderbird.exe is registered globally (at least in WindowsXP) so you can call the exe from anywhere. – Anthony Miller Jun 07 '11 at 15:25
  • I don't think so, but I don't have it installed so I can't say. However most programs don't register themselves in the `PATH` environment variable, so you have to CD into the correct directory – CharlesB Jun 07 '11 at 15:28
  • I dunno hows I dun it but I knows I dun it XD – Anthony Miller Jun 08 '11 at 13:19
  • is it possible to have the script actually send the email? – drooh Oct 31 '19 at 06:12