开发者

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

开发者 https://www.devze.com 2023-01-31 11:56 出处:网络
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?

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

精彩评论

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