I'm looking for something like chp.exe, it can run a command and return its pid. I can not use CHP.EXE because it seems to be reported as infected file in some antiviruses.
extract only the processId into a variable from query output:
This is pretty straightforward to do in PowerShell.
From there you could use it like an object by storing the output (
Getting it back to a batch script (if absolutely necessary) is a little tricky. If you're absolutely stuck on using a batch file, it would probably be easiest to write a PowerShell script that writes the relevant information to a file or registry key, call the PowerShell script from the batch file, and then read the file or reg key later in the batch script.
If you don't want to touch PowerShell at all then you'll have to resort to WMIC or tasklist to find the process after creating it.