[FIXED] adb shell check if screen is on windows cmd


I want to create bat script to turn on screen.
This command adb shell dumpsys input_method | find "mWakefulness=" is back me result


I want to check if adb back Asleep result if not i will turn it on, for example

cd /d "C:\Program Files (x86)\Remote\adb"
SET CHECK="adb shell dumpsys input_method | find "mWakefulness=""
if %CHECK% == "mWakefulness=Asleep" (
    adb shell input keyevent 26

But looks I’m on wrong way and can’t find how to do this, I’m not good in windows and their cmd.


Found solution

@echo off
cd /d "C:\Program Files (x86)\Remote\adb"

for /f "delims= tokens=1*" %%a in ('adb shell dumpsys power ^| findstr.exe "mWakefulness=Asleep"') DO (
for /f "delims== tokens=2*" %%S in ("%%a") do (
if "%%S" == "false" (goto move1) else (goto move2)

goto end

start /MIN cmd /c adb shell input keyevent 26
goto end


Answered By – user994461

Answer Checked By – Terry (FixeMe Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *