开发者

How to capture binary stdout of a console exe run from Powershell?

Is it possible to get Powershell to read the stdout of an exe into a byte[] instead of the usual text processed array of lines?

Best I've been able to do is this:

cmd 开发者_C百科/c foo.exe > foo.tmp
$b = [io.file]::readallbytes('foo.tmp')
del foo.tmp

Yucky, not to mention it is not streamable. Any better way to do this?


Got some info from the PowerShell team. The short answer is that unfortunately, it is not easy. :-(

The medium length answer is: http://poshcode.org/2175.

The long answer is: Capture and Redirect Binary Process Output

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜