MS-DOS

Moderators: blip
Number of threads: 389
Number of posts: 904

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to capture the result of this For command in to a variable? Posted by agarwaldvk on 24 Jul 2009 at 4:04 PM
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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.