1

When you specify STDOUT and STDERR files...

cmd.exe < "C:\in.txt" 1> "C:\out.txt" 2> "C:\err.txt"

...you end up creating a file even if that particular file stream was never written to within the console app (cmd.exe). Can this be avoided? I would rather not produce empty files.

Mario
  • 6,572
  • 3
  • 42
  • 74
  • 1
    It may be a ugly workaround, but you could check the size of stdout and stderr and erase them if they are empty at the end of your program – DrakaSAN Sep 11 '13 at 15:41

1 Answers1

0

The files are created by the cmd.com before running your program, so you have no control over it. The best you can do is making a batch file that "cleans up" after running your process by deleting out.txt and/or err.txt when they are empty.

Here is a link to an answer explaining how to detect and delete empty files.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523