for /F "delims=" %%a in ('wmic process call create "notepad.exe" ^| find "ProcessId"') do ( for %%b in (%%a) do set value=%%b ) echo %value%
This method returns the last word in a string, so it can be used on other lines with a variable number of words at the beginning.
source share