Okay, I learned that one can use &
or &&
to combine multiple commands into a single line, but it seems that variables that are set
I could not get an IF command to work with either call or cmd /v /c so I would like to offer another option for those who may need it: use FOR /F to declare and use a variable within a single command. For example:
FOR /F %i IN ('echo 123') DO (IF %i==123 echo done)
The %i is the variable that is set with the result of the IN command, which in this example is 'echo 123'.
For values with single quotes or spaces, use the "usebackq tokens=*" flag to put the command in backquotes:
FOR /F "usebackq tokens=*" %i IN (`echo "hello, ' ' world!"`) DO (IF %i=="hello, ' ' world!" echo done)