5
$\begingroup$

Mathematica-6, Windows-10.

How do you get Mathematica to start a task in the background? Function

Run["START \"xxx\" /D " <> dirname <> " /MIN /B /WAIT xxx.EXE"]; 

does not work in spite of the /MIN option. Option /B starts the task without creating a cmd.exe window but the task starts in the foregound. On the other hand,

Run["START \"xxx\" /D " <> dirname <> " /MIN /WAIT xxx.EXE"]; 

does start the task in the background but it creates a blank cmd.exe window in the foreground.

What I want is the task to start without one or two windows popping into existence on top of whatever I happen to be doing at the time.

$\endgroup$
3
  • 5
    $\begingroup$ You might have a hard time finding people with Mathematica 6 to test this on :) $\endgroup$
    – ktm
    Commented May 6, 2019 at 16:51
  • 1
    $\begingroup$ Perhaps the Mathematica version is not relevant. Can anyone with any recent version of Mathematica advise what to do, please? $\endgroup$
    – Tony
    Commented Jun 2, 2019 at 23:48
  • $\begingroup$ Come on, guys! Wake up! Someone, somewhere must know how to resolve this problem one way or the other. It is driving me round the bend! $\endgroup$
    – Tony
    Commented Aug 30, 2019 at 15:28

1 Answer 1

1
$\begingroup$

The solution to your problem is the Mathematica internal function StartProcess.

Here is a usage example:

pthExe=FileNameJoin[{NotebookDirectory[],"run.exe"}];
arguments={1,2,3};
process=StartProcess[Join[{pthExe},arguments]];
While[ProcessStatus[process] == "Running", Pause[0.1];];

Since I assume you want to work on the output of your external program, I added code to repeatedly pause mathematica's execution until the external program is finished.

This works in Mathematica 13.1 on Windows 11. I am not sure your problem has a solution without StartProcess[].

$\endgroup$

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.