@ECHO OFF
rem cmd /k 
rem SET "aaas=adb shell dpm set-device-owner com.emanuelef.remote_capture.debug/com.emanuelef.remote_capture.activities.admin"
rem echo is
chcp 65001 >nul


rem %aaas%
rem SET "err=%aaas%"
rem Echo Errorlevel after loop/expression completes: [%errorlevel%]

rem echo Hello | (set /p myVar= & set myVar)
rem echo %myVar%
adb shell dpm set-device-owner com.emanuelef.remote_capture.debug/com.emanuelef.remote_capture.activities.admin >temp.txt 2>&1
rem set /p myVarDate= < temp.txt
rem echo Date is %myVarDate%

::del temp.txt
rem Echo %aaa%

rem PAUSE >NUL
setlocal EnableDelayedExpansion

rem Define location of control file
set "ControlFile=temp.txt"

set N=0
rem Load control file values into variables
for /f "usebackq tokens=*" %%A in ("%ControlFile%") do (
  set /a N += 1
  set "Line!N!=%%A"
Echo %%A | find "no devices/emulators found" && (
    Echo e1
   rem  Echo Errorlevel: [%errorlevel%]
  ) || (
   rem Echo e1 Not found
   rem Echo Errorlevel: [%errorlevel%]
  )
Echo %%A | find "account" && (
    Echo e2
    rem Echo Errorlevel: [%errorlevel%]
  ) || (
   rem Echo e2 Not found
   rem Echo Errorlevel: [%errorlevel%]
  )
Echo %%A | find "is already set" && (
    Echo e3
    rem Echo Errorlevel: [%errorlevel%]
  ) || (
   rem Echo e3 Not found
   rem Echo Errorlevel: [%errorlevel%]
  )
Echo %%A | find "already several users" && (
    Echo e4
    rem Echo Errorlevel: [%errorlevel%]
  ) || (
   rem Echo e4 Not found
   rem Echo Errorlevel: [%errorlevel%]
  )
Echo %%A | find "java.lang.IllegalStateException" && (
    Echo e
    rem Echo Errorlevel: [%errorlevel%]
  ) || (
   rem Echo e Not found
   rem Echo Errorlevel: [%errorlevel%]
  )

Echo %%A | find "Device owner set to package" && (
    Echo s
    rem Echo Errorlevel: [%errorlevel%]
  ) || (
  rem Echo s Not found
   rem Echo Errorlevel: [%errorlevel%]
  )
)

rem Display variable values loaded from control file
rem echo Values read were:
rem set Line


echo end

pause