Merge with develop

This commit is contained in:
kervala 2016-02-02 19:51:11 +01:00
parent c85cbfc869
commit 0880232caa
2 changed files with 21 additions and 6 deletions

View file

@ -732,7 +732,22 @@ bool launchProgram(const std::string &programName, const std::string &arguments,
SetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, NULL ); 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) if (res)
{ {

View file

@ -719,7 +719,7 @@ void CPatchManager::stopPatchThread()
// **************************************************************************** // ****************************************************************************
void CPatchManager::deleteBatchFile() 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); chmod(batchFilename.c_str(), S_IRWXU);
#endif #endif
std::string cmdLine = "\"" + batchFilename + "\" " + LoginLogin + " " + LoginPassword; std::string arguments = LoginLogin + " " + LoginPassword;
if (!r2Mode) if (!r2Mode)
{ {
cmdLine += " " + toString(LoginShardId); arguments += " " + toString(LoginShardId);
} }
if (launchProgram("", cmdLine, false)) if (launchProgram(batchFilename, arguments, false))
{ {
exit(0); exit(0);
} }
else else
{ {
// error occurs during the launch // 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); throw Exception (str);
} }
} }