\" re开发者_StackOverflowdirecting it wi" />
开发者

Call a DOS command and redirect the output to a file

开发者 https://www.devze.com 2022-12-25 05:18 出处:网络
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 wi

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:

  1. calling a DOS command
  2. 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消