extending PATH on Windows?

Ulli Horlacher framstag at rus.uni-stuttgart.de
Thu Feb 18 11:50:48 EST 2016


eryk sun <eryksun at gmail.com> wrote:


> https://hg.python.org/cpython/file/v2.7.11/Tools/scripts/win_add2path.py
> 
> But there are a few issues with this script.

(... lot of flaws ...)

> Here's a new version for Python 2. I generalized the shell-variable
> replacement to a list of well-known folders.

Great script, I will save it for later usage!

But in the meantime I came to another solution:
Instead of modifying PATH systemwide, I modify it only for cmd.exe.

To achieve this, I set the registry key
"HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun"
to "%USERPROFILE%\autorun.cmd" and write in this file:
set PATH=%PATH%;%USERPROFILE%\Desktop

If there was already an old value in
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
it will be saved to %USERPROFILE%\autorun.cmd, too

This autorun.cmd is like .bashrc on UNIX.

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum IZUS/TIK         E-Mail: horlacher at tik.uni-stuttgart.de
Universitaet Stuttgart         Tel:    ++49-711-68565868
Allmandring 30a                Fax:    ++49-711-682357
70550 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/



More information about the Python-list mailing list