Solved How to store result of a command and parse it

January 27, 2016 at 22:28:40
Specs: Windows 7
I'm trying to extract the process ID of an app pool using dos. I'm using appcmd list wps /apppool.name:DefaultAppPool but the result I get is in the format WP "1234" <apppool:DefaultAppPool>. I want to store this output in a variable and extract the 1234 and pass it to another command.
How do I store and extract?

See More: How to store result of a command and parse it

Report •

#1
January 28, 2016 at 04:19:06
✔ Best Answer
 for /F "tokens=2" %%i in ('appcmd list wps /apppool.name:DefaultAppPool') do set var=%%~i


By the way the above script is NT batch and has nothing to do with DOS that doesn't exist in Windows 7.

message edited by IVO


Report •
Related Solutions


Ask Question