Page 1 of 1

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

Posted: 2023-Dec-21, 6:35 am
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