Why for loop wmic get processid return an extra invalid value?

Microsoft Windows
Post Reply
PiotrMP006
Posts: 19
Joined: 2021-Sep-01, 10:57 am

Why for loop wmic get processid return an extra invalid value?

Post by PiotrMP006 »

Hi

Why for loop wmic get processid return an extra invalid value?

Code: Select all

for /f "usebackq skip=1 delims=" %%a in (`wmic process where "name='cmd.exe' and commandline like '%%%~n0%%'" get processid 2^>nul`) do echo %%a
The first returned value %%a is the real processid
The second returned value %%a is a non-existent processid

Why?

Please help
Post Reply