【问题标题】:Windows command line script to search for file and then check permissions用于搜索文件然后检查权限的 Windows 命令行脚本
【发布时间】:2013-01-12 12:55:12
【问题描述】:

我有一个正在测试的命令行脚本,用于在整个目录中搜索给定文件(例如 cmd.exe)。该脚本运行良好,并返回每个找到的文件的完整路径。

for /r C:\ %i in (*) do @echo %~fi | find /I "cmd.exe"

现在我想扩展这个脚本,一旦找到文件检查权限(例如 icacls %~fi)。如果可能的话,我想将其保留在命令行上的单行中。

非常感谢任何帮助。

【问题讨论】:

    标签: windows file shell command-line batch-file


    【解决方案1】:
    for /f "tokens=*" %I in ('dir /b /s cmd.exe') do icacls "%I"
    

    这就是你要找的吗?如果您不想在单独的行上 cd 到 c:\ ,那么就这样改变它:

    pushd "\" && for /f "tokens=*" %I in ('dir /b /s cmd.exe') do (icacls "%I") && popd
    

    给你。单线。 :)

    【讨论】:

      猜你喜欢
      • 2012-06-15
      • 1970-01-01
      • 2014-09-10
      • 2018-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-04
      相关资源
      最近更新 更多