Please can someone kindly help me to join these two commands
netstat -ano | findstr 0.0.0.0:80
The output is as follows
Then need to pipe out PID results to next command that is
tasklist | findstr <PID from previous netstat command>
Any help would be greatly appreciated..
@echo off
for /f "tokens=5" %%# in ('netstat -ano ^| findstr "0.0.0.0:80"') do set "pid=%%#"
tasklist | findstr "%pid%"
or from command line:
for /f "tokens=5" %# in ('netstat -ano ^| findstr "0.0.0.0:80"') do set "pid=%#"
To get process name from command line:
for /f "skip=1 tokens=5" %a in ('qprocess %pid%') do set "image=%a"
from
for /f "skip=1 tokens=5" %%a in ('qprocess %pid%') do set "image=%%a"
It uses already created variable %pid%