批处理命令,循环中嵌套if判断,哪里出错了


@echo off
set devices=xxx.xx.xx.xx
::保存地址
set file_path=xxxx

for /l %%x in (1, 1, 2) do (
    echo %%x
    adb -s %devices% shell input keyevent 66
    ping -n 30 127.0.0.1>nul
    ::打印时间
    echo %time% >> %file_path%
    ::打印CPU信息
    adb -s %devices% shell top -n 1 |findstr User |findstr System >> %file_path%
    ::打印内存信息
    adb -s %devices% shell procrank | findstr com.hst.cx3 >> %file_path%
    for /f "delims=" %%i in ('adb -s %devices% shell dumpsys activity activities^|findstr Activity') do (set Join_Meeting=%%i)
    if "%Join_Meeting:MeetingActivity=%" neq "%Join_Meeting%" (
        adb -s %devices% shell input keyevent 4
        ::等待3s
        ping -n 3 127.0.0.1>nul 
        adb -s %devices% shell input keyevent 66
        ::等待3s
        ping -n 3 127.0.0.1>nul) else (
        ::打印时间
        echo %time% >> %file_path%
        echo Membership failed!>> %file_path%
        echo Membership failed!)
)
pause