#include #include #include test1(int argc, char **argv) { PROCESS_INFORMATION procInfo; STARTUPINFO aStartupInfo; HANDLE proc_handle; HANDLE my_handle=GetCurrentProcess(); char command[_MAX_PATH]; char command_line[4096]; int i; /* prepare the module name and the stupid long command line */ strcpy(command, argv[1]); command_line[0]='\0'; for(i = 2; i < argc; i++){ strcat(command_line, argv[i]); strcat(command_line, " "); } printf("%s %s\n", command, command_line); GetStartupInfo(&aStartupInfo); aStartupInfo.cb= sizeof(STARTUPINFO); aStartupInfo.dwFlags= 0; if (CreateProcess(command, command_line, NULL, NULL, TRUE, 0, // CREATE_NEW_CONSOLE, NULL, NULL, &aStartupInfo, &procInfo) != 0){ printf ("Process created \n"); proc_handle = procInfo.hProcess; printf("When ready press any key to continue\n"); WaitForSingleObject(proc_handle, INFINITE); printf ("Process finished\n"); } else{ printf ("Process creation failed\n"); } } int main(int argc, char **argv) { if(argc < 2){ printf ("Usage: %s ...\n", argv[0]); exit(1); } test1(argc, argv); }