//***************************************************************************** // Wait for finish when you run your Windows application on the command line. // by takaken Jul/2022 // Build: Visual Studio Community 2022 //***************************************************************************** #include #include int main(int argc, char* argv[]) { int i; char command[MAX_PATH]; STARTUPINFO s_info; PROCESS_INFORMATION p_info; // Get parameters strcpy_s(command, MAX_PATH, argv[1]); for (i = 2; i < argc; i++) { strcat_s(command, MAX_PATH, " "); if (strchr(argv[i], ' ')) strcat_s(command, MAX_PATH, "\""); strcat_s(command, MAX_PATH, argv[i]); if (strchr(argv[i], ' ')) strcat_s(command, MAX_PATH, "\""); } // Call application and Wait for finish ZeroMemory(&s_info, sizeof(STARTUPINFO)); s_info.cb = sizeof(STARTUPINFO); CreateProcess(NULL, command, 0, 0, FALSE, 0, NULL, NULL, &s_info, &p_info); CloseHandle(p_info.hThread); WaitForSingleObject(p_info.hProcess, INFINITE); CloseHandle(p_info.hProcess); return 0; }