I have the following batch file, which uses ADB to monitor device logs and searches for a string:
@ECHO OFF
ECHO Starting log monitor...
START /B adb.exe logcat > log
:LOOP
(TYPE log | FIND "string to find") > NUL
IF "%errorlevel%" == "1" GOTO LOOP
:END
ECHO String found!
The script starts the logcat
command, which runs asynchronously and in the background, using START /B
.
After the string is found, I would like to end the asynchronous logcat
command, as it is no longer needed.
Is there any way of the main script telling the asynchronous script to end?
I know that I could technically use adb.exe kill-server
or taskkill /F /IM adb.exe
to end all ADB processes, but I need to only end the logcat
command and continue running all other instances of ADB.
start
with a title and thentaskkill
with aWindowtitle
filterSTART "log_process" /B adb.exe logcat
and thenTASKKILL /FI "Windowtitle eq log_process"
returnsINFO: No tasks running with the specified criteria.
.windowtitle
method works for me.adb
may substitute your title by its own, so you need to use that instead.