Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

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

share|improve this question

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", 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.

share|improve this answer

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.