Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting and setting variables with .bat/cmd

How can i get the first output of the command where python and include all in the run.bat file ?

where python output:

C:\Users\Vermelhao>where python
C:\Program Files\Python\310\python.exe
C:\Users\Vermelhao\AppData\Local\Microsoft\WindowsApps\python.exe

Desired value "C:\Program Files\Python\310\python.exe"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

run.bat

pip install -r requirements.txt
"C:\Program Files\Python\310\python.exe" "./main.py"
pause

I want to assemble the run.bat file in a way that the python.exe path comes from the first path returned by the where python command

i’ve tried using set path=$(where python) but this holds the value like a string

>Solution :

where python returns the first Python found in the PATH. That is EXACTLY what you would get if you just ran python without specifying a path. So, what you ask is literally the same thing as this:

pip install -r requirements.txt
python ./main.py
pause
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading