I'm currently working on an mfc project where I call a number of commands via system. The problem with this is that it creates the black box which it is called in and as such I've been asked to find another method.
Some browsing of the internet has told me the only way this is possible is to use CreateProcess, unfortunately this function seems a little beyond me. My initial attempt to call it is as follows:
And while this shows that it is at least returning true, it doesn't appear to do anything. So either I'm missing something quite simple or there is alot more to it than I thought. Does the rest of the progamme stop until this command is done? How do you tell when it's complete?
Passing in "cmd.exe" "explorer C:" and "0" respectively and various other combinations there of. It seems to return false and thus goes into the else statement containing GetLastError(); which returns quite simply as 2. This unfortunately means little to me despite my best attempts at Google-fu.
I really am quite stuck, any help or suggestions would be greatly appreciated.
Changing cmd.exe to C:/WINDOW/System32/cmd.exe makes it calling the window (in a black box as I was trying to avoid). However won't make it call the command.
Any advice?
The WaitForSingleObject returns 258 - i.e process time out, so while I am creating cmd.exe I'm not calling the command.
Ok. Got round to trying to finish the program and found another issue. What I listed above works just fine for the example shown but when I try and use it with pipes to redirect the output it all falls apart.