Find Specific String and place it in a variable

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
booga73
Posts: 108
Joined: 30 Nov 2011 16:16

Find Specific String and place it in a variable

#1 Post by booga73 » 03 Mar 2013 10:45

What would be the best option to find a string value in the output without placing the value into a text file?

for instance, I run the command:

tasklist /NH /FI "pid eq 4"

has the result:

System 4 Services 0 7,972 K

I would like to get the string value " 4 " set to a value.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Find Specific String

#2 Post by Squashman » 03 Mar 2013 11:37

A FOR /F loop with the tokens=2.

Post Reply