I've used the sample code in KB article:
HOWTO: Spawn Console Processes with Redirected Standard Handles (Q190351)
...to launch a console program (a batch file calling Opus make).
The program works fine on my PC - the console program is launched, with stdout and stderr redirected to C:\stdout.txt and C:\stderr.txt, builds the target app, and the process is closed.
On other PCs, the process is launched, the redirection files are created, but the console application never seems to take enough time to do what it needs to do, and the redirection files are empty.
If I map a shared drive on my PC, and call my program under exactly circumstances (same working directory, same drive letter, same batch file being called), everything goes smoothly. I can't do anything to replicate the problem on my own PC, and all function calls return positively.
All PCs that I'm trying to get it to run on (including my own) are Win98 SE.
Has anybody else had problems with CreateProcess()?
Here is an snippet of my code:
// Set up the start up info struct.
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
siStartInfo.hStdOutput = hChildStdOut;
siStartInfo.hStdInput = hChildStdIn;
siStartInfo.hStdError = hChildStdErr;
siStartInfo.wShowWindow = SW_HIDE;
// Launch the process to be redirected
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
NULL, // use parent's environment
NULL, // use parent's current directory
&piProcInfo) == 0)
// Set global child process handle to cause threads to exit.
hChildProcess = piProcInfo.hProcess;
// Wait for the process to finish
// Close any unnecessary handles.