# ParallelDo with NotebookDirectory[]

I have a main directory with subdirectories numbered (1, 2, 3, ...). In each folder there is an exe file. I execute this code:

ParallelDo[RunProcess[NotebookDirectory[] <> ToString[i] <> "\\main.exe", ProcessDirectory -> NotebookDirectory[] <> ToString[i]], {i, 1, 10}]


And I get a bunch of errors: "A front end is not available; certain operations require a front end." and of course, the error mentioning that \$Failed is not a string. I stripped the problem down to this: RunProcess is allright, what is problem is that ParallelDo can't process NotebookDirectory[]:

ParallelDo[Print[NotebookDirectory[] <> ToString[i] <> "\\main.exe"], {i, 1, 10}]


(same errors)

What is the problem? How can I solve this?

• The subkernels do not have a front end connected, so they do not know what is the NotebookDirectory[]. Assign the notebook directory to a variable and use that in ParallelDo. – Szabolcs Mar 31 '17 at 23:31
• Oh! That works and the solution is so trivial...Thank you! – user16320 Mar 31 '17 at 23:39