I have looked at these posts addressing similar issues: From Python and Extract Silently and Command Line Option
None addresses my specific issue.
I would like to call 7za.exe (and possibly other console applications, that by default result in the shell command window) from within an application written in ANSI C without the shell prompt window popping up for each call. From within the Windows command shell, I can append > nul
to the end of a command line call of 7za, and it suppresses everything, as shown here:
However, I need to call it in a loop (several hundred times), from a Windows application, resulting in a constant flicker as Windows launches a shell then kills it when the command is complete.
So far I have tried appending > nul
, just as I illustrated in the command prompt image above, then using the system()
command, as well as a modified system command which launches exe in another process:
sprintf(command, "7za.exe x -y -o%s %s > nul", filepathUnComp, filepath);
system(command);
or:
SystemX(command);
Where SystemX is defined:
int SystemX(command)
{
STARTUPINFO sj;
PROCESS_INFORMATION pj;
int exit;
ZeroMemory( &sj, sizeof(sj) );
sj.cb = sizeof(sj);
ZeroMemory( &pj, sizeof(pj) );
if(CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &sj, &pj) == 0)
{
//AED_GetErrorMessage(AEDNV_FAILED_CREATE_PROCESS,cmd);
return -1;
}
// Wait until child processes exit.
WaitForSingleObject( pj.hProcess, IGNORE ); //ingnore signal
//Get exit code
GetExitCodeProcess(pj.hProcess, (LPDWORD)(&exit));
return exit;
}
Both of these methods result in the shell prompt window flicker.
Is there a way to run 7za.exe
within an application completely silent, that is, without instantiating the shell command window flicker?
If this is not possible using 7za, I am also open to hearing about other approaches.