It is possible to run MathKernel in batch mode by using undocumented command-line options -batchinput and -batchoutput:
math -batchinput -batchoutput < input.m > outputfile.txt
(where input.m
is the batch input file ending with the newline character, outputfile.txt
is the file to which the output will be redirected).
In Mathematica v.>=6 the MathKernel has undocumented command-line option:
-noicon
which controls whether the MathKernel will have visible icon on the Taskbar (at least under Windows).
The FrontEnd (at least from v.5) has undocumented command-line option
-b
which disables the splash-screen and allows to run the Mathematica FrontEnd much faster
and option
-directlaunch
which disables the mechanism which launches the most recent Mathematica version installed instead of launching the version associated with .nb files in the system registry.
Another way to do this probably is:
Instead of launching the
Mathematica.exe binary in the
installation directory, launch the
Mathematica.exe binary in
SystemFiles\FrontEnd\Binaries\Windows.
The former is a simple launcher
program which tries its hardest to
redirect requests for opening
notebooks to running copies of the
user interface. The latter is the
user interface binary itself.
It is handy to combine the last command line option with setting global FrontEnd option VersionedPreferences->True
which disables sharing of preferences between different Mathematica versions installed:
SetOptions[$FrontEnd, VersionedPreferences -> True]
(The above should be evaluated in the most recent Mathematica version installed.)
In Mathematica 8 this is controlled in the Preferences dialog, in the System pane, under the setting "Create and maintain version specific front end preferences".
It is possible to get incomplete list of command-line options of the FrontEnd by using undocumented key -h
(the code for Windows):
SetDirectory[$InstallationDirectory <>
"\\SystemFiles\\FrontEnd\\Binaries\\Windows\\"];
Import["!Mathematica -h", "Text"]
gives:
Usage: Mathematica [options] [files]
Valid options:
-h (--help): prints help message
-cleanStart (--cleanStart): removes existing preferences upon startup
-clean (--clean): removes existing preferences upon startup
-nogui (--nogui): starts in a mode which is initially hidden
-server (--server): starts in a mode which disables user interaction
-activate (--activate): makes application frontmost upon startup
-topDirectory (--topDirectory): specifies the directory to search for resources and initialization files
-preferencesDirectory (--preferencesDirectory): specifies the directory to search for user AddOns and preference files
-password (--password): specifies the password contents
-pwfile (--pwfile): specifies the path for the password file
-pwpath (--pwpath): specifies the directory to search for the password file
-b (--b): launches without the splash screen
-min (--min): launches as minimized
Other options include:
-directLaunch: force this FE to start
-32: force the 32-bit FE to start
-matchingkernel: sets the frontend to use the kernel of matching bitness
-Embedding: specifies that this instance is being used to host content out of process
Are there other potentially useful command-line options of the MathKernel and the FrontEnd? Please share if you know.
Related question.