Aqui está um arquivo em lote parcialmente inspirado por esta pergunta por Rogier:
@echo off
for /F "delims=" %%a in ('tasklist /fo list /v') do (call :Sub %%a)exit /b
:Subset Line=%*set BOL4=%Line:~0,4%set BOL13=%Line:~0,13%set Value=%Line:~14%if "%BOL4%"=="PID:" (set save_PID=%Value%exit /b)if "%BOL13%"=="Window Title:" (// Note . below.echo %Value% | findstr /r /c:"- Conversation.$" > nulif not errorlevel 1 (echo %save_PID%REM taskkill /pid %save_PID%)exit /b)exit /b
Descobri que precisava adicionar um . no final da expressão regular para o
echostring| findstr /rregular expression ending with $
forma de trabalhar. Eu estou supondo que echo está adicionando um CR ou talvez um CRLF extra à string , e que findstr está contando isso como um caractere ocorrendo entre a string e o final da linha.
Obviamente você irá descomentar o comando taskkill que você testou isso.