diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog index 17e5e990fd..823357dcc6 100644 --- a/pandora_agents/win32/ChangeLog +++ b/pandora_agents/win32/ChangeLog @@ -1,3 +1,11 @@ +2009-02-09 Ramon Novoa + + * windows/pandora_wmi.cc, + windows/pandora_wmi.h: Allow custom process creation flags. + + * pandora_windows_service.cc: Hide console window when calling + tentacle client. + 2009-02-09 Esteban Sanchez * main.cc: Added a new parameter --process to run the agent as a diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 7e8be45d3d..0d368030c1 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -207,7 +207,7 @@ Pandora_Windows_Service::copyTentacleDataFile (string host, string pass, string opts) { - int rc = 0; + bool rc = false; string var, filepath; string tentacle_cmd; @@ -244,26 +244,14 @@ Pandora_Windows_Service::copyTentacleDataFile (string host, filepath.c_str (), host.c_str ()); pandoraDebug ("Command %s", tentacle_cmd.c_str()); - rc = system (tentacle_cmd.c_str()); - switch (rc) { - - /* system() error */ - case -1: - pandoraLog ("Unable to copy %s", filename.c_str ()); - break; - - /* tentacle_client.exe returned OK */ - case 0: - break; - - /* tentacle_client.exe error */ - default: - pandoraDebug ("Tentacle client was unable to copy %s", - filename.c_str ()); - break; + rc = Pandora_Wmi::runProgram (tentacle_cmd.c_str(), CREATE_NO_WINDOW); + if (rc == true) { + return 0; } - - return rc; + + pandoraDebug ("Tentacle client was unable to copy %s", + filename.c_str ()); + return -1; } int diff --git a/pandora_agents/win32/windows/pandora_wmi.cc b/pandora_agents/win32/windows/pandora_wmi.cc index f136475755..3c0bbce3c6 100644 --- a/pandora_agents/win32/windows/pandora_wmi.cc +++ b/pandora_agents/win32/windows/pandora_wmi.cc @@ -520,9 +520,10 @@ Pandora_Wmi::convertWMIDate (string wmi_date, SYSTEMTIME *system_time) * Runs a program in a new process. * * @param command Command to run, with parameters + * @param flags Process creation flags */ bool -Pandora_Wmi::runProgram (string command) { +Pandora_Wmi::runProgram (string command, DWORD flags) { PROCESS_INFORMATION process_info; STARTUPINFO startup_info; bool success; @@ -537,7 +538,7 @@ Pandora_Wmi::runProgram (string command) { pandoraDebug ("Start process \"%s\".", command.c_str ()); cmd = strdup (command.c_str ()); - success = CreateProcess (NULL, cmd, NULL, NULL, FALSE, 0, + success = CreateProcess (NULL, cmd, NULL, NULL, FALSE, flags, NULL, NULL, &startup_info, &process_info); pandoraFree (cmd); diff --git a/pandora_agents/win32/windows/pandora_wmi.h b/pandora_agents/win32/windows/pandora_wmi.h index 93fb6ff441..f53ced9063 100644 --- a/pandora_agents/win32/windows/pandora_wmi.h +++ b/pandora_agents/win32/windows/pandora_wmi.h @@ -58,7 +58,7 @@ namespace Pandora_Wmi { void convertWMIDate (string wmi_date, SYSTEMTIME *system_time); - bool runProgram (string command); + bool runProgram (string command, DWORD flags = 0); bool startService (string service_name); bool stopService (string service_name); void runWMIQuery (string wmi_query,