ChildProcess search path

windows

#1

Hi jucers,

this should be a simple question… When I use ChildProcess::start(), I always need to specify a full path to the executable. It would be quite nice if it could use the path environment variable… I am however not sure why it doesn’t work already. I am on Windows here and looking at the implementation it falls down to CreateProcess in the end.

ok = CreateProcess (nullptr, const_cast<LPWSTR> (command.toWideCharPointer()),
                            nullptr, nullptr, TRUE, CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT,
                            nullptr, nullptr, &startupInfo, &processInfo) != FALSE;

Well, there is this lpEnvironment parameter which is described on MSDN as:

lpEnvironment [in, optional]

A pointer to the environment block for the new process. If this parameter is NULL, the new process uses the environment of the calling process.

So it looks like it should work. I am however not sure whether the parent process (that is, my JUCE app), can see the path correctly…


#2

OK guys, I have a this kind of “DING” effect with JUCE forum. I always tend to spend many hours bending my head over some tricky problem, then I finally give up and ask here. And DING, I solve the problem within minutes after asking the question. Maybe the need to formulate my thoughts help me in gaining the insight…

Anyway, it was enough just to restart the Visual Studio after modifying the PATH. I guess that similarly as the child process inherits the path from my application, my application inherits the PATH from VS. And for the path to be refreshed you always need to restart whatever it is your program runs from…