- wrapper: handle Windows .bat files as main programs

svn path=/trunk/boinc/; revision=24519
This commit is contained in:
David Anderson 2011-11-03 19:36:28 +00:00
parent ad2f3771da
commit c9302ae532
2 changed files with 38 additions and 12 deletions

View File

@ -8055,3 +8055,9 @@ David 3 Nov 2011
acct_mgr.cpp
app.cpp
cpu_sched.cpp
David 3 Nov 2011
- wrapper: handle Windows .bat files as main programs
samples/wrapper/
wrapper.cpp

View File

@ -442,7 +442,25 @@ int TASK::run(int argct, char** argvt) {
set_up_env_vars(&env_vars, nvars);
}
if (!CreateProcess(
BOOL success;
if (ends_with((string)app_path, ".bat")) {
char cmd[1024];
sprintf(cmd, "cmd.exe /c %s", command.c_str());
success = CreateProcess(
"cmd.exe",
app_path,
(LPSTR)cmd,
NULL,
NULL,
TRUE, // bInheritHandles
CREATE_NO_WINDOW|IDLE_PRIORITY_CLASS,
(LPVOID) env_vars,
exec_dir.empty()?NULL:exec_dir.c_str(),
&startup_info,
&process_info
);
} else {
success = CreateProcess(
app_path,
(LPSTR)command.c_str(),
NULL,
@ -453,7 +471,9 @@ int TASK::run(int argct, char** argvt) {
exec_dir.empty()?NULL:exec_dir.c_str(),
&startup_info,
&process_info
)) {
);
}
if (!success) {
char error_msg[1024];
windows_error_string(error_msg, sizeof(error_msg));
fprintf(stderr, "can't run app: %s\n", error_msg);