# math.exe vs wolfram.exe vs MathKernel.exe vs WolframKernel.exe (running scripts on Windows)

I generally consider Mma documentation very good. However, it is startlingly difficult to find useful information on running Mma batch scripts, especially on Windows. So ... just what would I enter is the Wolfram documentation search dialog to fetch this information? Here are things that don't work: math, math.exe, wolfram.exe, wolfram, MathKernel, and -script. Now WolframKernel brings up a page, but it is not useful. It does provide a promising link to http://reference.wolfram.com/language/tutorial/WolframLanguageScripts.html which is not completely devoid of information but (intentionally?) does not address Windows users. Worse, it suggests that MathKernel and math are equivalent, which (on Windows at least) is manifestly untrue.

So here is what I currently believe, not from the docs, but from looking at the binaries in my Mma folder and trying them out.

• math.exe and wolfram.exe are the same and can be used with the -script option to run scripts
• MathKernel.exe and WolframKernel.exe are the same but (contrary to the Wolfram page above) are different from the other two commands in some unspecified ways and (again contrary to the page) cannot but used with the -script option to run scripts. (Or at least, contrary to that page, output intended for stdout does not go there.)

So, what are these 4 files actually, and where are they documented, and where in particular is the documentation for Windows users as to how to use them?

These two small programs -- math.exe is the same as wolfram.exe, and MathKernel.exe is the same as WolframKernel.exe -- are kernel loaders, which provide an interface to the same main kernel code residing in the dynamic library WolframEngine.dll (also known as mathdll.dll in versions prior to 10.1.0).

Both accept the same command line options as documented for wolfram and WolframKernel. The main difference is that wolfram.exe is a console application, while WolframKernel.exe is a GUI, windowed application offering some basic copy and paste, font selection and scrolling functionality.

The standard behavior of the Windows OS is that upon launching a console application, it is attached to the console of the parent process (for example, cmd.exe) if present, otherwise a new console is created. That is not the case for GUI applications, which by default run without a console, and therefore do not have stdin, stdout and stderr.

While the latter is not impossible to code around, it is hardly necessary in this case, as wolfram.exe is provided as a true console application suitable for scripting purposes.

The kernel launchers organization is slightly different on other operating systems: on Linux, math/wolfram/MathKernel/WolframKernel are all the same shell script, which launches the kernel loader binary. On MacOS X, there is only a MathKernel/WolframKernel binary loader.

Something to keep in mind about the documentation that it is the same on all platforms, and so is written as much as possible in a general and platform-independent manner, without delving into OS specifics in many cases.

• Can the information you provide somehow be extracted from the available docs? If not, can you indicate your source? Thanks! – Alan May 21 '15 at 18:08
• Actually I think none of it is so arcane that it couldn't be deduced by reading the documentation, inspecting the layout and launching these executables plus certain familiarity with Windows. I hope my answer is still useful in some way and doesn't sound like complete guesswork. – ilian May 21 '15 at 18:39
• My query was not meant in any way to challenge your description. As you can see, my question engaged in similar inferences about these executables. That said, what did you mean by "inspecting the layout"? Thanks. – Alan May 21 '15 at 20:09
• The same as in the question really -- just looking at the files installed, trying them out etc. But I agree the documentation definitely could be tweaked to be more helpful to Windows standalone kernel users. – ilian May 21 '15 at 20:25
• @Vladimir Nowadays, the kernel has broader functionality, and powers products other than Mathematica, hence the new name. MathKernel.exe is kept for backward compatibility. – ilian Jun 2 '15 at 19:44