Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It seems there are a lot of related topics but I haven't found an answer.

I want to automatically quit Mathematica after some procedures are done but dialog window appears:

1 + 1;

enter image description here

One can put this inside Button

        1 + 1; NotebookSave[EvaluationNotebook[]];

what will work but I need it works as a part of procedure because the notebook is called automatically and no one is going to click OK.

This Q&A is almost a duplicate of undisputed FrontEndTokenExecute but there was the work around.

I appreciate a work around but also the general question, how to stop or automatically agree with Dialogs is what I'm interested in.

Maybe it's relevant: Win XP/Win 7 Mathematica V9.0.0.1

share|improve this question
@Anon but when to close? :) It is called via WindowsTaskManager but I can switch to cmd if you show me how to catch some mark from MMA that will tell cdm to close it. – Kuba Aug 23 '13 at 11:21
By the way, isn't it strange that it offers to put the result to the MessageWindow since I'm closing MMA?:) – Kuba Aug 23 '13 at 11:34
Hah, I deleted my comment in like two seconds didn't think you'd see it... I realized it might not be viable for you. But what I meant was to save your notebook content into an .m file and execute it via command line. I didn't think there was reason to open a notebook in the first place if noone was there to see it. – C. E. Aug 23 '13 at 14:29
When I want to automatically close Mathematica, I do ListPlot3D[bigdata] and try to rotate the view :D :D – R. M. Aug 23 '13 at 14:44
up vote 17 down vote accepted

There's a separate FE token that can do this.

share|improve this answer
Ahh, it's also on complete list there, thank you. Do you maybe know the answer for general question, about preventing Dialogs? The answer that we can't do anything is also information :) – Kuba Aug 23 '13 at 18:39
@Kuba, if you run the front end with the -server command-line option, then it will not prompt dialog boxes. But it will also not be usable by the user. This is, for example, how the kernel command UsingFrontEnd launches the kernel. Since you don't provide very much context for your question, it's not clear to me whether this is a useful answer to your question. – John Fultz Aug 26 '13 at 20:35
I was thinking about something like Check but detecting dialogs. Also with functionality to automatically agree or not with them. I do know if it is possible, just asking. – Kuba Aug 28 '13 at 10:03
@Kuba it's not possible to do anything like what you're asking for globally for arbitrary Mathematica commands. If you're sticking to fully documented Mathematica functions, you shouldn't ever see interactive prompts unless that's the purpose of the function (e.g., Input). But many of the FE tokens were implemented only for the purpose of user interaction through the menu system, and do not represent the gold standard of end-to-end design that we generally apply to fully documented functions. – John Fultz Aug 28 '13 at 16:29
Thank you, I think it exhausts the topic. :) – Kuba Aug 28 '13 at 18:08

As a workaround, try this:

1 + 1;

This will only work if the kernel evaluations have actually finished, you can't use it half-way through a calculation.

share|improve this answer
Thank you, it works for my purposes. Can you explain why this is considered by Mathematica different evaluation or something? – Kuba Aug 23 '13 at 13:05
@Kuba, the message in the dialog says that a notebook contains a running evaluation. As I understand it, scheduled tasks are not associated with any specific notebook, so there is no reason for the front end to complain. – Simon Woods Aug 23 '13 at 13:53
Why not close all Untitled notebooks also? : RunScheduledTask[ Map[NotebookClose, Select[ Notebooks[], FreeQ[ NotebookInformation[#], "FileName"] & ]]; FrontEndExecute[FrontEndToken["FrontEndQuit"]]]; NotebookInformation[#], "FileName"] & ]]; – Rolf Mertig Aug 23 '13 at 16:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.