如何打印特定元素

时间:2019-11-06 20:16:22

标签: windows batch-file cmd

如何从以下输出中仅打印第二个元素?

"java.exe","7184","RDP-Tcp#20","2","231,440 K","Running","CAB\27","0:00:59","start-app"

所以基本上我只想得到“ 7184”

这是我正在使用的脚本:

 @ECHO OFF

  echo Stoping the Application ...
    echo.
 tasklist /v /fo csv | findstr /i "start-app"

谢谢

1 个答案:

答案 0 :(得分:0)

使用批处理文件,您可以像这样:

@echo off & color 0B
echo(
echo Stopping the Application ...
@for /f "tokens=2 delims=," %%a in ('tasklist /v /fo csv ^| findstr /i "start-app"') do (
    echo %%a & Taskkill /PID %%a
)
pause