Call a DOS command and redirect the output to a file
I'd like to have a macro in Visual Studio 2005 that calls a DOS command and redirects the output (stdout and stderr) to a file. Just calling the command and ">" re开发者_StackOverflowdirecting it will not capture stderr, so there are two parts to this:
- calling a DOS command
- capturing both stderr and stdout to a file during that call
I'd then like to open this file in Visual Studio after the command completes.
I'm new to Visual Studio 2005 macro writing, and VB/VBA, so that's the kind of help that I'm looking for.
Thanks, Mark
In DOS, > or 1> is stdout, and 2> is stderr. So, you could say
myprog.exe 1> out.txt 2> err.txt
to send them to separate files, or
myprog.exe 1>2> both.txt
to send them to both.
In VB/VBA, you could use the Shell command to call this (assuming you didn't know that already).
精彩评论