I am executing batch commands via a C program with the CreateProcess function. I check to see if the process has terminated with the GetExitCodeProcess function, by checking to see if the process exit code equals anything except STILL_ACTIVE. This works fine with commands like "cmd /c echo Hello World", but for commands like "cmd /c dir c:\windows" or "cmd /c dir c:\windows & exit", cmd.exe will never terminate. Either command when launched thru the command prompt will terminate as expected. Does anyone know why it never terminates when launched via CreateProcess? Thanks a lot.
相关问题
- the application was unable to start correctly 0xc0
- Handle button click in another application
- xcopy include folder
- Batch file if string starts by
- Jenkins - cmd is not recognized
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- Why windows 64 still makes use of user32.dll etc?
- Can WM_NEXTDLGCTL be used with non-dialog windows?
- Extracting columns from text file using Perl one-l
- Windows EventLog: How fast are operations with it?
- Are resource files compiled as UNICODE or ANSI cod
- How can one batch file get the exit code of anothe
- Command line escaping single quote for PowerShell
Apparently I have to start to read the stdout/stderr pipe in the loop which checks to see if the process is still running, as well as read it after the process has terminated. Rather than just read it after the process has terminated. Many thanks to Wimmel for posting the answer.