Hello, I have problems using the 'CreateProcess' win32api function. I have been searching a bit here but I'm not able to make it run.

The scenario: I have a very simple server program and I would like to enable it to work with php; I also have php5 (php-cgi.exe); I'm trying to call the php-cgi.exe to interpret the php files and dump the result on a temporary file in my server's temporary folder, but I need to know when the interpret have finishet the job. I have created a simple CreateProcess demo to test it (and to not post the whole code here) and that's it

Code:
#include <windows.h>
#include <stdio.h>

int main()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
char bff[512];

//init the STARTUPINFO struct
memset(&si,0,sizeof(si));
si.cb=sizeof(si);

//setup the command line arguments
sprintf(bff,"-f \"C:\\Documents and Settings\\Aeiou\\SERVIDOR\\dirweb\\demo.php\" >\"C:\\Documents and Settings\\Aeiou\\SERVIDOR\\dirtmp\\out00.txt\");

//create the proc with those args
if(!CreateProcess("C:\\PHP\\php-cgi.exe",bff,NULL,NULL,0,0,NULL,NULL,&si,&pi))
    {
    printf("ERROR");
    getchar();
    return 0;
    }

//wait till the proc ends
WaitForSingleObject(pi.hProcess,INFINITE);

//close all
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
getchar();
return 0;
}
The "C:\\PHP\\php-cgi.exe" is the path to the php interpret, the "C:\\Documents and Settings\\Aeiou\\SERVIDOR\\dirweb\\demo.php" is the path to the client request (ok, for that sample is a fixed request file), and the "C:\\Documents and Settings\\Aeiou\\SERVIDOR\\dirtmp\\out00.txt" will be the dumped result.

If I runt that code, instead of getting the output file, create it and dumping the result, it shows the result (or the errors if there's any) on the command prompt, so there's no output file. But if I work manually from the command prompt with files in the same folder as the php interpret it works well (obviously that isn't what I look for).

I have also tried specifiyng the working directory

Code:
CreateProcess("C:\\PHP\\php-cgi.exe",bff,NULL,NULL,0,0,NULL,"C:\\PHP",&si,&pi)
but the result is the same, it dumps the result to the command prompt and there's no output file. Finally I have also tryed to call the interpret with all the arguments (argument #0 = path to the interpret + arguments, argument#1 = null, etc...) but the result is an uppercase ERROR on the command line prompt.


How can I do that?


Thank's in advance,
Niara