PowerShell:将命令行工具的输出重定向到主机

时间:2012-05-06 14:19:37

标签: powershell

我正在尝试调用命令行.exe工具(x264转换某些视频)并在PowerShell主机中打印其输出。

需要将大量参数传递给x264。到目前为止,我无法使用Invoke-Item cmdlet运行它,所以我尝试了

[diagnostics.process]::start($com, $args).WaitForExit()

这样可以正常工作,但会打开旧cmd窗口以显示输出。出于好奇,我想知道如何在主机中显示输出。

2 个答案:

答案 0 :(得分:2)

我可能完全没有,没有PowerShell大师,但你不能只运行以下内容吗?

$args = @("list", "of", "args", "here")
& x264.exe $args

答案 1 :(得分:0)

当cmd窗口打开时,它是否显示输出?如果是这样,也许这会有所帮助。

Start-Process c:\x264.exe -ArgumentList $args -Wait -NoNewWindow