I'm using C++ Builder and trying to run a program with CreateProcess. For example:
This compiles fine, however it doesn't run cmd.exe. (having "cmd.exe" as the argument doesn't help either). The MessageBox with the error is executed.
if ( !CreateProcess("cmd", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) )
MessageBox(NULL, "Error running cmd.exe", "Error", NULL);
If I use system("cmd"); it works just fine. This is the same for other programs that I have in my PATH, for example my gcc compiler. Is there any way I can run these with CreateProcess without specifying the full path? Because CreateProcess gives you a lot more control, like a process handle and ID that you can use with WaitForSingleObject() etc...