【问题标题】:Is there a way to suppress extraction progress window for exe created by 7zip?有没有办法抑制由 7zip 创建的 exe 的提取进度窗口?
【发布时间】:2015-11-02 12:01:21
【问题描述】:

我正在使用 powershell 调用 exe CS.exe。它显示进度条。

&"$Path\CS.exe" -o"$OutputPath" -y | Out-Null

有没有办法抑制这种情况?

【问题讨论】:

    标签: powershell cmd 7zip


    【解决方案1】:

    如果您谈论的是 PowerShell 进度条,可以通过将 $ProgressPreference 变量设置为 SilentlyContinue 来抑制它:

    # When set to SilentlyContinue, Progress bars will be supressed
    $ProgressPreference = 'SilentlyContinue'
    

    如果您看到的进度条是可执行文件写入的 stderr 输出,您可以使用 cmd 样式的输出重定向(所有版本)来抑制它:

    &"$Path\CS.exe" -o"$OutputPath" -y >$null 2>&1
    

    或使用流重定向(PowerShell 3.0 及更高版本):

    &"$Path\CS.exe" -o"$OutputPath" -y *>$null
    

    您可以阅读有关重定向的更多信息:Get-Help about_Redirection

    【讨论】:

      猜你喜欢
      • 2016-12-04
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-14
      • 2011-04-16
      • 1970-01-01
      • 2010-09-16
      相关资源
      最近更新 更多