I need to run the 2nd command on windows cmd only if the 1st one fails, in another scneario, I want to open python setup after checking if it is installed or not.
I used this command
python --version || path/to/python_install.exe
as I know the || means run if the last command failed. but it only runs the first one.
All of the comments guided me to the right way to do it.
I used this great working code:
:: Check for Python Installation
python --version 3>NUL
if errorlevel 1 goto errorNoPython
:: Reaching here means Python is installed.
:: Execute stuff...
:: Once done, exit the batch file -- skips executing the errorNoPython section
goto:eof
:errorNoPython
echo.
echo Error^: Python not installed
"C:\Program Files\used\systems\innoventiq\accumanager\required\excutables\python-3.7.3-amd64.exe"
Open Command Prompt > Type Python Or py > Hit Enter If Python Is Installed it will show the version Details Otherwise It will Open Microsoft Store To Download From Microsoft Store
Just go in cmd and type where python if it installed it will open a prompt .
Sometimes it may not work if environment variable is not set up, so you can also check by where python in cmd. If where python returns something hot to that path and see for python.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With