【问题标题】:Windows Command to Delay The Output And Then Find a StringWindows 命令延迟输出然后查找字符串
【发布时间】:2018-10-15 14:55:00
【问题描述】:

我正在尝试在 Windows 命令行上执行以下操作:

gpresult /Scope User /v获取当前用户组策略设置的结果,然后使用ping或timeout等命令,创建延时后再执行

findstr "ScreenSaveActive"

我曾尝试过以下操作,例如,尝试完成上述但未成功:

gpresult /Scope User /v | timeout /t 5 /nobreak | findstr "ScreenSaveActive"

【问题讨论】:

    标签: regex windows command-line timeout findstr


    【解决方案1】:

    在 Powershell 中使用以下命令更容易做到这一点:

    gpresult /Scope User /v | out-string -stream | select-string "ScreenSaveActive"
    

    你可以像这样从 cmd 运行它:

    Powershell -Command "gpresult /Scope User /v | out-string -stream | select-string 'ScreenSaveActive'"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-23
      • 1970-01-01
      • 2021-11-07
      • 2017-11-29
      • 1970-01-01
      • 2011-11-25
      • 2013-07-22
      • 1970-01-01
      相关资源
      最近更新 更多