From 0880232caa20247b3ec89348ddd30351ae050d0c Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 2 Feb 2016 19:51:11 +0100 Subject: [PATCH] Merge with develop --- code/nel/src/misc/common.cpp | 17 ++++++++++++++++- code/ryzom/client/src/login_patch.cpp | 10 +++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 6888dd24f..d586e4638 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -732,7 +732,22 @@ bool launchProgram(const std::string &programName, const std::string &arguments, SetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, NULL ); } - BOOL res = CreateProcessA(programName.empty() ? NULL:programName.c_str(), (char*)arguments.c_str(), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi); + const char *sProgramName = programName.c_str(); + + std::string args; + + // a .bat file must have first parameter to NULL and use 2nd parameter to pass filename + if (CFile::getExtension(programName) == "bat") + { + sProgramName = NULL; + args = "\"" + programName + "\" " + arguments; + } + else + { + args = arguments; + } + + BOOL res = CreateProcessA(sProgramName, (char*)args.c_str(), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi); if (res) { diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 68b29b687..3273dc95d 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -719,7 +719,7 @@ void CPatchManager::stopPatchThread() // **************************************************************************** void CPatchManager::deleteBatchFile() { - deleteFile(UpdateBatchFilename, false, false); + deleteFile(ClientRootPath + UpdateBatchFilename, false, false); } // **************************************************************************** @@ -938,21 +938,21 @@ void CPatchManager::executeBatchFile() chmod(batchFilename.c_str(), S_IRWXU); #endif - std::string cmdLine = "\"" + batchFilename + "\" " + LoginLogin + " " + LoginPassword; + std::string arguments = LoginLogin + " " + LoginPassword; if (!r2Mode) { - cmdLine += " " + toString(LoginShardId); + arguments += " " + toString(LoginShardId); } - if (launchProgram("", cmdLine, false)) + if (launchProgram(batchFilename, arguments, false)) { exit(0); } else { // error occurs during the launch - string str = toString("Can't execute '%s': code=%d %s (error code 30)", UpdateBatchFilename.c_str(), errno, strerror(errno)); + string str = toString("Can't execute '%s': code=%d %s (error code 30)", batchFilename.c_str(), errno, strerror(errno)); throw Exception (str); } }