I have a enterprise software product with a new data exporting facility. One of the exporting features is an ability to use middleware executables in command lines and execute them to complete an export. The idea being our export system generates data in arbitrary text formats, and for those organizations who need their exported data in proprietary binary formats, the ability to export text command lines to an external executable is the method for generating these externally controlled binary data blobs. (Yes, we realize this could be a security exploit. This feature is wrapped up with multiple security checks.)
I have been trying WxExecute() and wxProcess() (as well as platform specific variations for over a day) and so far I have zilch results. Sometimes my virus software (Malwarebytes) quarantines the executable at launch, but most often it runs without error, but generates no output from the launched program. (Yes, I am attempting these launches from the main thread.)
In my test logic, my test command lines typically contain IO redirection, something like this:
Code: Select all
c:\MachineId.exe > c:\ExportComm\bsjnk.txt
Is it correct to say the logic will need to look at the command line, and if any shell commands, piping, or IO redirection is taking place, the logic needs to call wxShell()? (Interesting, my test use of wxShell() with the above line generates an assert() inside wWidgets.)
Likewise, it is correct to say the logic will need to look at the command line, and if it passed the above checks, but I see background suspension (the & character at the end) then that & character needs to be striped off? (Because i'm running these async anyway?)
I'm seeing recent forum posts saying wExecute() works, but I've not got it to work once yet... Below are some attempts.
(BTW: compiling on Win10, using Visual Studio 2013, i7 with 32 gigs RAM (if that matters))
Code: Select all
// event.GetString() contains the cmd line delivered here from another thread
// generates no output, and no error return value:
msg = event.GetString();
cx_int ret = wxExecute( msg, wxEXEC_ASYNC | wxEXEC_HIDE_CONSOLE );
if (ret == 0)
{
msg = wxString::Format("Export Connector Exec: failure to execute external program.");
ReportLog(msg);
} /**/
/* this triggers an assert() inside wShell():
msg = wxString::Format("c:\\windows\\sysWOW64\\cmd.exe /c start %s &", event.GetString());
cx_int ret = wxShell( msg );
if (ret != 0)
{
msg = wxString::Format("Export Connector Exec: failure to execute external program.");
ReportLog(msg);
} /**/
/* generates no output, and no error return value:
msg = wxString::Format("c:\\windows\\sysWOW64\\cmd.exe /C /D /F:ON start %s", event.GetString());
cx_int ret = wxExecute( msg, wxEXEC_ASYNC | wxEXEC_HIDE_CONSOLE );
if (ret == 0)
{
msg = wxString::Format("Export Connector Exec: failure to execute external program.");
ReportLog(msg);
} /**/