Wmic process where (Name like '%CHP%') get caption, name, commandline, ProcessId | more
amostra real:
Wmic process where (Name like '%ie%') get caption, name, commandline, ProcessId | more
Saída:
WmicprocessgetProcessId
extraiapenasoprocessIdemumavariáveldasaídadaconsulta:
ProcID.cmd:
@ECHOOFFFOR/F%%TIN('Wmicprocesswhere^(Name^="explorer.exe"^)get ProcessId^|more +1') DO (
SET /A ProcessId=%%T) &GOTO SkipLine
:SkipLine
echo ProcessId = %ProcessId%
Saída:
ProcessId = 2372