CreateProcess Error, help with parameters?

I am trying to open a pdf via firefox with CreateProcess(), I am a beginner and know nothing about using CreateProcess, but the MSDN article says the following:

To run a batch file, you must start the command interpreter;
set lpApplicationName to cmd.exe and set lpCommandLine to the
following arguments: /c plus the name of the batch file.

Therefore I created a batch file that runs perfectly fine with the system() command, so there are no problems with the batch file.

I get system error 2 and I can't figure out why the system can't find the file; I don't know if its the batch file, the exe in the batch file, the pdf doc in the batch file or the location of cmd.exe... Any help is greatly appreciated...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 void openPDF(char scansQueue[][MAX_NAME], int index)
{
	cout<< "OPENING PDF!!!!!!!!!!!!!!!!"<<endl;
	// build open path
	char openPath[300];
	char procCommand[MAX_NAME]="C:\\firefox";
	char cmdEXE[MAX_NAME]="C:\\Windows\\System32\\cmd.exe";
	fstream outfile;
	outfile.open("C:\\firefox.bat");
	copyCString(openPath,"\"C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe\"");
	outfile << openPath;
	outfile << ' ';

	copyCString(openPath,"\"C:\\Scans\\");
	catArray(openPath,scansQueue[index]);
	catArray(openPath,"\"");
	STARTUPINFO si; 
    PROCESS_INFORMATION pi; 
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );
	cout<<"PROCESS ATTEMPT"<<endl;
	if(!CreateProcess((LPCTSTR)cmdEXE ,(LPWSTR)procCommand, NULL, NULL, false, 0, NULL, NULL, &si, &pi))cout << GetLastError();cout<<"PROCESS FAILED TO EXECUTE!!!";

}
Last edited on
Topic archived. No new replies allowed.