I use M9 under windows 7 on a command prompt as: MathKernel -noprompt -script file.m

On execution, there is a like a kernel window opened and then closed immediately. How can I avoid this window and run my script in silence? thanks


1 Answer 1


This is not really a Mathematica, but an operation system issue.

There are several ways on windows to avoid the cmd window showing up:

1) batch file:

@echo off
start /B MathKernel -noprompt -script file.m

2) WSScript file:

Set WshShell = CreateObject("WScript.Shell")
cmds=WshShell.RUN("MathKernel -noprompt -script file.mt", 0, True)
Set WshShell = Nothing

I'd go with the first example (using /MIN instead of /B will run your MathKernel, but with a minimized window, which can be helpful, if you need to have a look on logs etc.)

On Windows 7 you have a decent shell (PowerShell) you can script your MathKernel call in a .ps1 script and run it with:

powershell.exe -windowstyle hidden -file c:\path\to\you\ps1script.ps1


With the powershell approach you need to sign your script in order to be allowed to execute it. Either you sign it really or just add this option to the powershell.exe call:

-ExecutionPolicy ByPass

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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