capture string output of command line application in an environment variable


John Faughnan

This must have been answered here, but I found it hard to search for

I vaguely remember years ago batch files and utilities that would
capture the output (stdout) of a command line application and put it
into an environment variable.

I'd like to do this with a command line application (WCD) in XP.

Can anyone point me to a reference or give some hints on the method?

(e-mail address removed)

meta: jfaughnan, jgfaughnan, DOS, XP, windows, command line, CMD,
batch file, environment variable, output, redirect, filter, < , >
pipe, shell, program, DOS


Perhaps something like......

for /f %%i in ('set username') do (set abc = %%i)
set abc

Putting the above 2 lines into a .bat file and running in DOS mode shows abc
contains the output of the command "set username"

for /? at command prompt for info on "for" command


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question