Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Command Prompt -- redirect output of program to variable  (Read 4545 times)

0 Members and 1 Guest are viewing this topic.

warhawk11

  • Guest
Command Prompt -- redirect output of program to variable
« on: June 04, 2009, 01:09:33 PM »
I'm trying to pipe the output of a program (a string) into a variable. When I try the below code, the command runs but the variable isn't created:

Code: [Select]
C:\Programlocation\program.exe | set /p variable=

This seems like it should be pretty straightforward...

Thanks,

J

Dusty



    Egghead

  • I could if she would, but she won't so I don't.
  • Thanked: 75
  • Experience: Beginner
  • OS: Windows XP
Re: Command Prompt -- redirect output of program to variable
« Reply #1 on: June 06, 2009, 02:43:27 AM »
Welcome to the CH forums.

Try this:
Code: [Select]
for /f "delims=*" %%1 in ('C:\ProgramLocation\Program.exe') do (
    set variable=%%1
)

Good luck

One good deed is worth more than a year of good intentions.