1

What I would like to do is create a batch file that will temporarily add a environment variable to the Python executable. From there call the executable and open another script from the batch file. I'm very new to batch and have been researching this, so far I've found that to add a environment variable I would need something like:

set env="path/to/exe"

And to call a script I would need to use:

call "path/to/script"

My question being, if I where to combine the two two and then call the script, would I be able to do something like this:

set env="python.exe"
call "python script.py"

Will this work like I would expect it to?

1 Answer 1

2

Well the CALL is used for calling (opening) batch files. If you wanted to open a python script through batch (and set the environment) you would have use the STARTcommand and code it like this:

set env=python.exe
start python script.py

This should work (combined) if you have the Python environment.

4
  • The executable will be in the directory that the script is located in, I don't know if this will work yet it's still a work in progress, well more of an idea in progress. Do you think the call command will still work as expected with what you now know?
    – ekultek
    Commented Dec 17, 2016 at 2:23
  • The CALL as far to my knowledge is to start Batch applications only, however the start command starts all file types.
    – PryroTech
    Commented Dec 17, 2016 at 2:27
  • You must remove the space after the = sign, otherwise it becomes part of the variable value...
    – aschipfl
    Commented Dec 17, 2016 at 20:36
  • @PryroTech, you need to remove the space, not to add another one -- see my edit; in addition, I recommend to use the quoted syntax set "env=python.exe"...
    – aschipfl
    Commented Dec 20, 2016 at 13:46

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.