mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-04 09:14:47 +00:00
Changed: Detect .bat file in launchProgram and adapt syntax of CreateProcess
This commit is contained in:
parent
fe26d14df4
commit
850ea0d211
2 changed files with 19 additions and 4 deletions
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -938,14 +938,14 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue