Possible Duplicate:
trying to create a simple shell in c for win32 api
I’m doing some C programming in Windows for a low level coding assignment and I’m trying to get this create process to work however. I am try to trying to execute a command as a process, any command you can put into the dos prompt. I’m mainly trying execute “dir”
in a separate process. Can anyone see why this wouldn’t work?
if (!CreateProcess(NULL, "dir",
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi))
{
fprintf(stderr, "Create Process directly has Failed\n");
return -1;
}
Since dir is a cmd.exe built in you need to run cmd , ie set
lpApplicationNametocmd.exeandlpCommandLineto dir