How to capture the result of this For command in to a variable? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to capture the result of this For command in to a variable?

agarwaldvkagarwaldvk Posts: 1Member
Hi Everybody

This is my first posting on this forum. Could someone help me with this, please!

I have a batch file and have a 'for' command in there that gets the number of computers connected to (or are turned on) my home network at the time that it is run. The result it gives is correct. What I want to be able to now do is to store the result of this command in to a variable and subsequently check if this number is 1 or not. If it is, then do a command (that bit I know) but I do not know how to store this result and then check if it meets a certain criteria.

The code and the sample result are as below :-

Code
echo off
net view > ctr1.txt
for /F "skip=3 eol=T" %%i in (ctr1.txt) do (find /C /I "\" ctr1.txt)


Result
---------- CTR1.TXT: 1

The "1" is the result that I want to be able to test for.

Any suggestions/help shall be highly valued.


Best regards


Deeapk Agarwal
Sign In or Register to comment.