Skip to content

Instantly share code, notes, and snippets.

@olegchir
Created September 5, 2017 09:47
Show Gist options
  • Save olegchir/f5ea7481eaf19bc721fbdb2ba0131227 to your computer and use it in GitHub Desktop.
Save olegchir/f5ea7481eaf19bc721fbdb2ba0131227 to your computer and use it in GitHub Desktop.
STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
ZeroMemory( &pi, sizeof(pi) );
// Spawn creates a cmd.exe window. CreateProcess doesn't.
//if ( _spawnl( _P_WAIT, szFileNameBAT, szFileNameBAT, NULL ) ) {
if ( !CreateProcess( szFileNameBAT, szFileNameBAT, NULL, NULL, false,
CREATE_NO_WINDOW, NULL, NULL, &si, &pi ) ) {
MyErrorFunc( "CreateProcess( \"%s\" ): %d", szFileNameBAT, GetLastError() );
goto MyErrorHandling;
}
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment