How do I redirect output to a file with CreateProcess?

前端 未结 5 2062
不思量自难忘°
不思量自难忘° 2020-11-27 19:52

I tried using CreateProcess to run a simple command like hg > test.txt. I tried running the string as a whole (as opposed to separating it into an applicatio

5条回答
  •  日久生厌
    2020-11-27 20:13

    CreateProcess() launches processes, it is not a command line itnerpreter. It doesn't know what ">" is and won't do the stream redirection for you. You need to open the file test.txt yourself and pass the handle to it to CreateProcess inside the STARTUPINFO structure: CreateProcess STARTUPINFO

提交回复
热议问题