如何捕获从Powershell运行的控制台exe的二进制标准输出?

时间:2010-12-19 05:26:30

标签: powershell

是否有可能让Powershell将exe的stdout读入byte []而不是通常的文本处理数组?

我能做的最好的就是:

cmd /c foo.exe > foo.tmp
$b = [io.file]::readallbytes('foo.tmp')
del foo.tmp

哎呀,更不用说它不是流光的了。有没有更好的方法呢?

1 个答案:

答案 0 :(得分:4)

从PowerShell团队获得了一些信息。简而言之,不幸的是,这并不容易。 : - (

中长答案为:http://poshcode.org/2175

答案很长:Capture and Redirect Binary Process Output

相关问题