1.

Solve : Command Prompt -- redirect output of program to variable?

Answer»

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,

JWelcome to the CH forums.

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

Good luck



Discussion

No Comment Found