diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index eef72cd50..0ef54d85c 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -917,93 +917,44 @@ void CPatchManager::executeBatchFile() extern void quitCrashReport (); quitCrashReport (); -#ifdef NL_OS_WINDOWS - // Launch the batch file - STARTUPINFO si; - PROCESS_INFORMATION pi; - - ZeroMemory( &si, sizeof(si) ); - si.dwFlags = STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; // SW_SHOW + bool r2Mode = false; - si.cb = sizeof(si); +#ifndef RY_BG_DOWNLOADER + r2Mode = ClientCfg.R2Mode; +#endif - ZeroMemory( &pi, sizeof(pi) ); - - // Start the child process. - string strCmdLine; - bool r2Mode = false; - #ifndef RY_BG_DOWNLOADER - r2Mode = ClientCfg.R2Mode; - #endif - if (r2Mode) - { - strCmdLine = UpdateBatchFilename + " " + LoginLogin + " " + LoginPassword; - } - else - { - strCmdLine = UpdateBatchFilename + " " + LoginLogin + " " + LoginPassword + " " + toString(LoginShardId); - } - if( !CreateProcess( NULL, // No module name (use command line). - (char*)strCmdLine.c_str(), // Command line. - NULL, // Process handle not inheritable. - NULL, // Thread handle not inheritable. - FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. - NULL, // Use parent's starting directory. - &si, // Pointer to STARTUPINFO structure. - &pi ) // Pointer to PROCESS_INFORMATION structure. - ) - { - // error occurs during the launch - string str = toString("Can't execute '%s': code=%d %s (error code 30)", UpdateBatchFilename.c_str(), errno, strerror(errno)); - throw Exception (str); - } - // Close process and thread handles. -// CloseHandle( pi.hProcess ); -// CloseHandle( pi.hThread ); + std::string batchFilename; +#ifdef NL_OS_WINDOWS + batchFilename = CPath::standardizeDosPath(ClientRootPath); #else - // Start the child process. - bool r2Mode = false; + batchFilename = ClientRootPath; +#endif -#ifndef RY_BG_DOWNLOADER - r2Mode = ClientCfg.R2Mode; + batchFilename += UpdateBatchFilename; + +#ifdef NL_OS_UNIX + // make script executable under UNIX + chmod(batchFilename.c_str(), S_IRWXU); #endif - string strCmdLine; + std::string cmdLine = "\"" + batchFilename + "\" " + LoginLogin + " " + LoginPassword; - strCmdLine = "./" + UpdateBatchFilename; + if (!r2Mode) + { + cmdLine += " " + toString(LoginShardId); + } - chmod(strCmdLine.c_str(), S_IRWXU); - if (r2Mode) + if (launchProgram("", cmdLine, false)) { - if (execl(strCmdLine.c_str(), strCmdLine.c_str(), LoginLogin.c_str(), LoginPassword.c_str(), (char *) NULL) == -1) - { - int errsv = errno; - nlerror("Execl Error: %d %s", errsv, strCmdLine.c_str()); - } - else - { - nlinfo("Ran batch file r2Mode Success"); - } + exit(0); } else { - if (execl(strCmdLine.c_str(), strCmdLine.c_str(), LoginLogin.c_str(), LoginPassword.c_str(), toString(LoginShardId).c_str(), (char *) NULL) == -1) - { - int errsv = errno; - nlerror("Execl r2mode Error: %d %s", errsv, strCmdLine.c_str()); - } - else - { - nlinfo("Ran batch file Success"); - } + // error occurs during the launch + string str = toString("Can't execute '%s': code=%d %s (error code 30)", UpdateBatchFilename.c_str(), errno, strerror(errno)); + throw Exception (str); } -#endif - -// exit(0); } // ****************************************************************************