PGP批处理文件从列表中检查用户

时间:2018-06-07 23:03:07

标签: batch-file

我想存储!输出[%% n]! | findstr / c:变量中的“global”。如果将此设置为不起作用的东西或创建一个if语句,如果它显示那么检查单词然后回显它在这里,如果不是那么它不在这里。

@echo off 
SETLOCAL
SETLOCAL enabledelayedexpansion

for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
for /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)
for /f "usebackq" %%i IN (`hostname`) DO SET MYVAR=%%i

set cmpInfo=%mydate%, %mytime%, %MYVAR%
set cmd1="%ProgramFiles(x86)%\PGP Corporation\PGP Desktop"
set "output_cnt=0"


cd %cmd1%
for /f "tokens=*" %%a in ('pgpwde --list-user --disk 0') DO (
    set /a output_cnt+=1
    set "output[!output_cnt!]=%%a"
)

for /L %%n in (1 1 !output_cnt!) DO (
   **!output[%%n]! | findstr /c:"global"**
)

pause

1 个答案:

答案 0 :(得分:0)

我不确定你想要做什么,但我猜这是你想要做的。

for /L %%n in (1 1 !output_cnt!) DO (
    echo !output[%%n]! | findstr /i /c:"global" >nul 2>&1 && echo yes || echo no
)

但我认为你也可以这样做。

for /f "tokens=*" %%a in ('pgpwde --list-user --disk 0') DO (
    set "output=%%a"
    if not "!output:global=!"=="!output!" (
        echo yes
    ) else (
        echo no
    )
)