Computing.Net > Forums > Programming > Batch: how to assign command to Var

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch: how to assign command to Var

Reply to Message Icon

Name: pednoy
Date: September 14, 2004 at 01:28:50 Pacific
OS: Win XP
CPU/Ram: Xeon 1g
Comment:

Dear all,

I need help.
Is there a way to redirect command output to variable. An output is a text string and has space bar.

Example is file a.txt has a content "AB CD EF"
Can I type a.txt and reirect output to %A%?

set %A%=type a.txt is not work.


Thankyou verymuch



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: September 14, 2004 at 02:15:41 Pacific
Reply:

Your question is solved by For /F (again!)

@Echo Off

For /F "tokens=* delims=" %%A in ('Type a.txt') Do Set MyVar=%%A
Echo [%MyVar%]

chaining statements and managing variables is mostly achieved through that command. A must to build effective value scripts.


0
Reply to Message Icon

Related Posts

See More


Why doesnt my Serial ATA ... Creating fault-logging so...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch: how to assign command to Var

how to pass command to child shell? www.computing.net/answers/programming/how-to-pass-command-to-child-shell/13388.html

batch how to cr charecter www.computing.net/answers/programming/batch-how-to-cr-charecter/10633.html

how to check batch file www.computing.net/answers/programming/how-to-check-batch-file/2856.html