批处理,用tasklist可不可以让a=其中1个进程的PID

来源:百度知道 编辑:UC知道 时间:2024/06/27 11:32:48

@echo off
for /f "tokens=1,2" %%a in ('tasklist^|find "explorer.exe"') do set "a=%%b"
echo explorer.exe进程的PID为%a%
pause

上面是用批处理得出explorer进程的PID,如果是直接在cmd中的话:
for /f "tokens=1,2" %a in ('tasklist^|find "explorer.exe"') do echo -%b-

你要它进程做什么.?? 如果是要结束进程的话可以用: taskkill /im "进程名" /f