Index: LocalProcess.cpp =================================================================== --- LocalProcess.cpp (revision 12312) +++ LocalProcess.cpp (working copy) @@ -66,9 +66,10 @@ #endif #ifdef PLATFORM_WIN32 -bool Win32CreateProcess(const char *command, const char *envptr, STARTUPINFOW& si, PROCESS_INFORMATION& pi) +bool Win32CreateProcess(const char *command, const char *envptr, STARTUPINFOW& si, PROCESS_INFORMATION& pi, const char *processWorkDirectory) { // provides conversion of charset for cmdline and envptr WString wcmd(command); + WString wpwd(processWorkDirectory); int n = wcmd.GetCount() + 1; Buffer cmd(n); memcpy(cmd, wcmd, n * sizeof(wchar)); @@ -84,11 +85,11 @@ memcpy(env, wenv, (len + 2) * sizeof(wchar)); } #endif - return CreateProcessW(NULL, cmd, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, (void *)envptr, NULL, &si, &pi); + return CreateProcessW(NULL, cmd, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, (void *)envptr, wpwd, &si, &pi); } #endif -bool LocalProcess::DoStart(const char *command, const Vector *arg, bool spliterr, const char *envptr) +bool LocalProcess::DoStart(const char *command, const Vector *arg, bool spliterr, const char *envptr, const char *processWorkDirectory) { LLOG("LocalProcess::Start(\"" << command << "\")"); @@ -173,7 +174,7 @@ } command = cmdh; } - bool h = Win32CreateProcess(command, envptr, si, pi); + bool h = Win32CreateProcess(command, envptr, si, pi, processWorkDirectory); LLOG("CreateProcess " << (h ? "succeeded" : "failed")); CloseHandle(hErrorWrite); CloseHandle(hInputRead); @@ -338,6 +339,8 @@ LLOG("[" << a << "]: <" << (args[a] ? args[a] : "NULL") << ">"); #endif//DO_LLOG + if(processWorkDirectory) + chdir(processWorkDirectory); LLOG("running execve, app = " << app << ", #args = " << args.GetCount()); if(envptr) { const char *from = envptr; Index: LocalProcess.h =================================================================== --- LocalProcess.h (revision 12312) +++ LocalProcess.h (working copy) @@ -58,14 +58,14 @@ typedef LocalProcess CLASSNAME; - bool DoStart(const char *cmdline, const Vector *arg, bool spliterr, const char *envptr = NULL); + bool DoStart(const char *cmdline, const Vector *arg, bool spliterr, const char *envptr = NULL, const char *processWorkDirectory = NULL); public: - bool Start(const char *cmdline, const char *envptr = NULL) { return DoStart(cmdline, NULL, false, envptr); } - bool Start2(const char *cmdline, const char *envptr = NULL) { return DoStart(cmdline, NULL, true, envptr); } + bool Start(const char *cmdline, const char *envptr = NULL, const char *processWorkDirectory = NULL) { return DoStart(cmdline, NULL, false, envptr, processWorkDirectory); } + bool Start2(const char *cmdline, const char *envptr = NULL, const char *processWorkDirectory = NULL) { return DoStart(cmdline, NULL, true, envptr, processWorkDirectory); } - bool Start(const char *cmd, const Vector& arg, const char *envptr = NULL) { return DoStart(cmd, &arg, false, envptr); } - bool Start2(const char *cmd, const Vector& arg, const char *envptr = NULL) { return DoStart(cmd, &arg, true, envptr); } + bool Start(const char *cmd, const Vector& arg, const char *envptr = NULL, const char *processWorkDirectory = NULL) { return DoStart(cmd, &arg, false, envptr, processWorkDirectory); } + bool Start2(const char *cmd, const Vector& arg, const char *envptr = NULL, const char *processWorkDirectory = NULL) { return DoStart(cmd, &arg, true, envptr, processWorkDirectory); } #ifdef PLATFORM_POSIX LocalProcess& DoubleFork(bool b = true) { doublefork = b; return *this; }