I am trying to automate the submission of many executables with variable parameter values via Mathematica on Windows 10 x64.
Running the executable from Mathematica works great for executables that take no arguments via the following:
Run["myExecutable.exe"]
If – however – you wish to feed in parameter values, the following is the closest I get to the desired behavior (where the “900…” are my arguments to be passed to the EXE):
RunProcess["myExecutable.exe","ExitCode","900 0.01 2 30 30"]
However, on my machine this requires 15% CPU usage by the executable (as expected) & another 15% CPU usage from the Mathematica kernel itself, unlike the Run[~]
above. This is because RunProcess[~]
returns something to the Mathematica kernel, whereas Run[~]
does not; this bug is reported here. This halves the efficiency of scripting and makes it unfeasible!
To avoid this bug in RunProcess[~]
, I am wondering if there is either:
1) a likely undocumented way to make
RunProcess[~]
not return anything, thus preventing the kernel from chunking away @ 15% CPU usage waiting on an exit code (or other info),2) a way to feed in arguments via
Run[~]
instead?
For (1), I’ve no idea; there is no “None” option available as argument 2.
For (2), there are guides on how to make Run[~]
feed in arguments here from a WRI employee and elsewhere on the Stack Exchange site, e.g. here.
(2) boils down to my not understanding what the Windows Command Prompt needs to see in order to feed in those parameters. This is addressed in part in the first of the above two links, but I cannot for the life of me figure it out. However, I would think RunProcess[~]
must know, because it works, it just hogs 2x the necessary CPU usage! But I do not know what it “says” to the command prompt in order to run the executable and feed in the arguments! Another resource regarding this topic is here
Does anyone know how to do this? While I don’t have a minimal working example with a personally compiled exectuable, the behavior can be observed using this (again from here):
RunProcess[{"sleep","10"}]
vs.
Run["sleep 10"]
However, unlike for the Linux instantiation I believe users in that referenced question are using, Run["sleep 10"]
does not pass the argument appropriately on Windows, (i.e. Run["myExecutable.exe 900 0.01 2 30 30"]
does not work on Windows as an equivalent to the resource-hogging yet functional RunProcess["myExecutable.exe",...]
above)! π
Does anyone know how to use Run[~]
to appropriately pass multiple arguments to an executable on Windows??? I do not have spaces in my executable file path (simply SetDirectory[~]
to its folder before-hand), just multiple arguments.