/*************************************************************************************/ /* File Name : launch.cpp */ /* Log File Name : output.txt */ /* Author : Meng Yi Yee */ /* Class : CS 431 */ /* Date : Oct 4, 1999 */ /* */ /* This program shows an approach to developing multi-process program. This program */ /* can read more than 1 file. Each file contains a list of programs that to be */ /* executed. The main function of running the list of programs is 'CreateProcess' */ /* which will read the command line from the file and execute the programs. */ /* */ /* The main program first reads the user command from DOS. The user will input */ /* 'launch ..' to run this program. */ /* and so on are optional. This way, the user can call for more than 1 file to */ /* execute the list of programs in different files. From the assignment, it would be */ /* 'launch launchset.txt'. In this case the argc=2, argv[0]=launch, */ /* argv[1]=launch.txt. Then, it will read a sigle line at a time and call */ /* 'CreateProcess' to launch the particular program. All the result will store in */ /* 'output.txt'. */ /* */ /*************************************************************************************/ #include "stdafx.h" #include #include #include int main(int argc, char* argv[]) { //Declare local variables and initialize variables FILE *fid; FILE *fout; char cmdLine[100]; int MAX_LINE_LEN=100; char lpCommandLine[20]; STARTUPINFO startInfo; PROCESS_INFORMATION processInfo; //Output instruction when there is an error executing the program and exit //the program if (argc<2) { printf("\nError running 'launch.exe', please try again\n"); printf("launch ...\n"); printf(" and so on are optional\n"); printf("Example: launch launchset.txt\n"); return 0; } //Open 'output.txt' as an output file. If fail, exit the program fout=fopen("output.txt", "w"); if (!fout) { fprintf (stderr, "Open file output.txt failed\n"); return 0; } // for (int i=1; i