I'm trying to read in a file of commands and create a seperate process for each one of the commands. I can use fscanf to get the commands from the file but fscanf only reads in characters until the first space which is useless because there may be command line parameters
e.g. C:\windows\system32\notepad.exe bob.txt
I'm trying fgets which reads in entire lines but it includes the end of line marker at the end of each line it reads and CreateProcess doesn't seem to like end of line markers as CommandLine names. The last command in the file executes fine as it does not have an eoln marker.
I keep getting Error Code 123. I think the problem is that fgets is including the eoln marker and CreateProcess doesn't like it.
Can anyone shed some light on the subject?
Thanks in advance
<< NON-WORKING CODE HERE >>
int main(int argc, char *argv)
FILE *fp = NULL;
fp = fopen("launchset.txt", "r");
fgets(temp, sizeof(temp), fp);
sInf.cb = sizeof(sInf);
if (!CreateProcess(NULL, temp, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL, &sInf, &pInf))
fprintf(stderr, "Create Process failed on error %d\n", GetLastError());