Here\xe2\x80\x99s 是一个批处理文件,部分受到Rogier这个问题的启发:
\n\n\n\n\n\n\n
@echo off\n\n
for /F "delims=" %%a in (\'tasklist /fo list /v\') do (
\n\xc2\xa0 \xc2\xa0 \xc2\xa0 call :Sub %%a
\n)
\nexit /b
\n\xc2\xa0\n
:Sub
\nset Line=%*
\nset BOL4=%Line:~0,4%
\n \set BOL13=%Line:~0,13%
n \set Value=%Line:~14%
nif "%BOL4%"=="PID:" (
\\xc2\xa0 \xc2\xa0 \xc2\xa0 set save_PID=%Value%
n\xc2\xa0 \xc2\xa0 \xc2\xa0 exit /b
\n)
\n \nif "%BOL13%"=="Window Title:" (\xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 //注意 . 以下。
\n\xc2\xa0 \xc2\xa0 \xc2\xa0 echo %Value% | findstr /r /c:"- Conversation.$" > nul
\n\xc2\xa0 \xc2\xa0 \xc2\xa0 if not errorlevel 1 (
\n\xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 echo %save_PID%
\n\xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 REM taskkill /pid %save_PID%
\n\xc2\xa0 \xc2\xa0 \xc2\xa0 )
\n\xc2\xa0 \xc2\xa0 \xc2\xa0 exit /b
\n)
\nexit /b
.我发现我需要在正则表达式的末尾添加一个
\n\n\n\n
echo以$结尾的字符串正则表达式| findstr /r
\xc2\xa0 I\xe2\x80\x99m 猜测是在字符串echo中添加了一个 CR 或者一个额外的 CRLF ,并且将其计算为字符串和行尾之间出现的字符。findstr
显然,您将取消注释掉taskkill您已经测试过的命令。
| 归档时间: |
|
| 查看次数: |
8737 次 |
| 最近记录: |