You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell环境下无法重定向exe程序帮助输出的问题求助

PowerShell环境下无法重定向exe程序帮助输出的问题求助

各位好,我现在碰到个头疼的问题:想把drivers.exe这个二进制程序的帮助信息输出重定向到output.txt文件里,但试了好几种方法都没成功,想请大家帮忙排查下问题出在哪。

我已经尝试过这些命令,结果都不尽如人意:

  • 用wmic调用程序的方式:
PS D:\user\drivers> wmic process call create ".\drivers.exe -h" > output.txt

查看生成的output.txt,里面只有wmic自身的执行结果,完全不是drivers.exe的帮助信息:

Exécution (Win32_Process)->Create()

Méthode exécutée.

Paramètres de sortie :

instance of __PARAMETERS

{

ReturnValue = 9;

};
  • 用Invoke-Expression捕获输出再写入文件:
PS D:\user\drivers> $output = Invoke-Expression ".\drivers.exe -h"
PS D:\user\drivers> $output|  Out-File -FilePath ".\output.txt"

结果output.txt是空的,啥内容都没写进去。

  • 直接通过管道输出到Out-File:
PS D:\user\drivers> .\drivers.exe -h | Out-File -FilePath ".\output.txt"

奇怪的是,执行这个命令时,帮助信息直接显示在控制台里了,但output.txt还是空的。控制台显示的帮助内容如下:

Usage: /s /e /f

/s - Un-package the package in silent mode (not showing user interaction UI)

/f - Runtime switch that overrides the default target path specified in build time

/e - Prevent execution of default executable file specified in build time.
Only extracting the content files to target folder(Use this with /s /f)

我甚至试过Start-Transcript,也没能成功捕获输出。有没有大佬知道这是怎么回事?要怎么做才能把这个帮助信息成功写到文件里啊?

备注:内容来源于stack exchange,提问作者Afff

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 08:05:31