Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I need to check in my batch script what python --version response is.
python --version
For that, I want to enter to a variable the output of the python --version commands :
set /u cmd=python --version %cmd%
What should i do next ?
Use a for loop.
for /f "delims=!" %%i in ('python --version') do set VAR=%%i echo %VAR%
I changed %cmd% to %VAR% as it is a bad idea to set variable names that resemble system commands such as cmd which is in fact cmd.exe
set
cmd
cmd.exe
Add a comment
Required, but never shown
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.
Explore related questions
See similar questions with these tags.