1

I'm trying to assign a command output to a variable for later use, without the use of temp files. Following answers from here, using for /f "delims=" %%i in ('command') do set output=%%i, the prompt flashes too fast so I can't read the error message.

The command in question is echo ;%PATH%; | find /C /I "%PATH2%" where %PATH2% is an earlier set variable containing the path to the python folder. I'm trying to check if the user has the path set, and depending on that continue on. So I want to assign the command output from that command to a variable, in this case "output".

4
  • Why can't you use temporary files? Commented Aug 18, 2016 at 22:27
  • 3
    Do not double-click the batch-file, open a command prompt window and run it from there, then you can read its output and error messages... You will need to escape the pipe symbol like ^| within a command line parsed by for /F... Commented Aug 18, 2016 at 22:29
  • 1
    You can also add @pause at the end of your batch file, this way it will wait for an input before to close Commented Aug 19, 2016 at 12:04
  • Possible duplicate of Capture output command CMD Commented Nov 24, 2016 at 16:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.