Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103006

Re: extending PATH on Windows?

From Thorsten Kampe <thorsten@thorstenkampe.de>
Newsgroups comp.lang.python
Subject Re: extending PATH on Windows?
Date 2016-02-16 14:38 +0100
Message-ID <mailman.167.1455629937.22075.python-list@python.org> (permalink)
References <n9umo3$9lg$1@news2.informatik.uni-stuttgart.de> <mailman.160.1455625190.22075.python-list@python.org> <n9v58k$dcl$1@news2.informatik.uni-stuttgart.de>

Show all headers | View raw


* Ulli Horlacher (Tue, 16 Feb 2016 12:38:44 +0000 (UTC))
> 
> Thorsten Kampe <thorsten@thorstenkampe.de> wrote:
> > * Ulli Horlacher (Tue, 16 Feb 2016 08:30:59 +0000 (UTC))
> > > I need to extend the PATH environment variable on Windows.
> > 
> > 1. Add the path component yourself into HKEY_CURRENT_USER and make 
> > sure it's not there already (pure Python).
> 
> Preferred!
> What is HKEY_CURRENT_USER? Another environment variable?

It's a hive in the Windows registry and the equivalent of `~/.*` in 
Linux terms (HKEY_LOCAL_MACHINE[/Software] being the equivalent of 
`/etc`). The fact that you're asking indicates that you should read 
about that in advance. 

The task itself is definitely not that hard. Maybe someone has 
already asked at StackOverflow. But the devil's in the detail.

Some things to consider

- Python is not by default installed on Windows, so you have to use a 
way to run your script without (PyInstaller for instance).

- by default there is no entry in HKCU, so you have to create it 
first (under HKEY_CURRENT_USER\Environment).

- you need to create the correct type (REG_SZ, null-terminated 
string)

- Windows paths are semicolon separated (not colon).

- Windows only module for the Registry: 
https://docs.python.org/3/library/winreg.html

Thorsten

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-16 08:30 +0000
  Re: extending PATH on Windows? Thorsten Kampe <thorsten@thorstenkampe.de> - 2016-02-16 13:19 +0100
    Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-16 12:38 +0000
      Re: extending PATH on Windows? Thorsten Kampe <thorsten@thorstenkampe.de> - 2016-02-16 14:38 +0100
      Re: extending PATH on Windows? Thorsten Kampe <thorsten@thorstenkampe.de> - 2016-02-16 14:43 +0100
        Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-17 17:49 +0000
          Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-17 13:02 -0600
            Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-17 20:29 +0000
              Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-17 15:17 -0600
                Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-17 22:37 +0000
                Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-18 16:55 +0000
                Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-19 12:07 -0600
          Re: extending PATH on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-17 19:53 -0500
            Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-18 16:24 +0000
              Re: extending PATH on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-18 21:57 -0500
                Re: extending PATH on Windows? pyotr filipivich <phamp@mindspring.com> - 2016-02-18 19:39 -0800
                Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-19 10:42 +0000
                Re: extending PATH on Windows? Chris Angelico <rosuav@gmail.com> - 2016-02-19 21:48 +1100
                Re: extending PATH on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-19 07:45 -0500
                Re: extending PATH on Windows? Gisle Vanem <gvanem@yahoo.no> - 2016-02-19 15:18 +0100
                Re: extending PATH on Windows? pyotr filipivich <phamp@mindspring.com> - 2016-02-19 09:04 -0800
                Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-19 12:04 -0600
                Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-19 12:42 -0600
                Re: extending PATH on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-19 19:57 -0500
                Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-20 07:31 -0600
          Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-18 06:54 -0600
            Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-18 16:50 +0000
  Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-16 07:17 -0600

csiph-web