Can a python script persistently change a Windows environment variable? (elegantly) -


Which of my following, is it possible to create a Python script that constantly changes a Windows environment variable?

On the end of the Python interpreter, changes in OSENWEN are not turned on. If I was scripting it on Unix, then I could do something like this:

  set foo = `myscript.py`  

But alas, Cmd.exe does not do anything that behaves like a back-tick of shah I have seen a very long winding solution ... very well we can certainly improve on this: / P>

  for / f "tokens = 1 * delims =" %% a in 'dragon. \ Myscript.py') path =% path%; %%  

Determine that it is a better solution than Microsoft's mind!

Note : Exact duplicate.

Your long-winded solution is perhaps the best idea; I do not believe it is possible that directly from Python. This article suggests another method using a temporary batch file:


Comments