change windows system path from cygwin python?

Discussion in 'Python' started by gry@ll.mit.edu, Dec 15, 2004.

  1. Guest

    [Windows XP Pro, cygwin python 2.4, *nix hacker, windows newbie]

    I want to write some kind of install script for my python app that
    will add c:\cygwin\usr\bin to the system path. I don't want
    to walk around to 50 PC's and twiddle through the GUI to:

    My Computer --> Control Panel --> System --> Advanced --> Environment


    How can a python, or even a .bat script modify the system PATH?
    It doesn't appear to be in the registry.
    , Dec 15, 2004
    #1
    1. Advertising

  2. wrote:

    > [Windows XP Pro, cygwin python 2.4, *nix hacker, windows newbie]
    >
    > I want to write some kind of install script for my python app that
    > will add c:\cygwin\usr\bin to the system path. I don't want
    > to walk around to 50 PC's and twiddle through the GUI to:
    >
    > My Computer --> Control Panel --> System --> Advanced --> Environment
    >
    >
    > How can a python, or even a .bat script modify the system PATH?
    > It doesn't appear to be in the registry.


    If you're just wanting to add a path to the system environments you can do:

    "set path=c:\path\to\whatever" # As a line in a Batch file


    --
    Harlin Seritt
    Harlin Seritt, Dec 15, 2004
    #2
    1. Advertising

  3. >
    > I want to write some kind of install script for my python app that
    > will add c:\cygwin\usr\bin to the system path. I don't want
    > to walk around to 50 PC's and twiddle through the GUI to:
    >
    > My Computer --> Control Panel --> System --> Advanced --> Environment
    >
    >
    > How can a python, or even a .bat script modify the system PATH?
    > It doesn't appear to be in the registry.
    >

    It is in the registry
    All users = local machine - "System\CurrentControlSet\Control\Session
    Manager\Environment"
    Current User = Current User - Environment

    The only issue with this is you will have to reboot for it take effect.
    Jeff Lindholm, Dec 15, 2004
    #3
  4. <> wrote:

    > I want to write some kind of install script for my python app that
    > will add c:\cygwin\usr\bin to the system path. I don't want
    > to walk around to 50 PC's and twiddle through the GUI to:
    >
    > My Computer --> Control Panel --> System --> Advanced --> Environment
    >
    >
    > How can a python, or even a .bat script modify the system PATH?
    > It doesn't appear to be in the registry.


    did you look under

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment

    ?

    </F>
    Fredrik Lundh, Dec 15, 2004
    #4
  5. On Wed, Dec 15, 2004 at 06:43:35PM +0000, Jeff Lindholm wrote:
    > The only issue with this is you will have to reboot for it take
    > effect.


    The above is not quite true -- at least under NT/2000/XP. The reboot is
    only necessary for the SCM (and services) to notice the change.
    Otherwise, you just need to send a special Windows event:

    http://support.microsoft.com/?kbid=104011

    There are tools that will set environment variables and send the
    required event. For example, see the following:

    http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/setx-o.asp

    Jason

    --
    PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
    Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6
    Jason Tishler, Dec 15, 2004
    #5
  6. Peter Hansen Guest

    Fredrik Lundh wrote:
    > <> wrote:
    >>How can a python, or even a .bat script modify the system PATH?
    >>It doesn't appear to be in the registry.

    >
    > did you look under
    > HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment


    And see also this helpful recipe:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/55993
    Peter Hansen, Dec 15, 2004
    #6
  7. Guest

    The _winreg api looks helpful; unfortunately, I'm trying to stick to
    what can be got
    from the cygwin install -- no _winreg. Simplicity of installation is
    quite important.
    (I'm using cygwin to get the xfree86 X-server, which is the whole point
    of this exercise)

    I have found the cygwin command-line "regtool" for munging the
    registry, so I plan
    to use that via os.popen.
    Thanks all for pointing me to the right place in the registry!
    , Dec 16, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    416
  2. Replies:
    0
    Views:
    417
  3. WELCOME to

    , Sep 3, 2003, in forum: Python
    Replies:
    1
    Views:
    502
    Robin Becker
    Sep 5, 2003
  4. Replies:
    0
    Views:
    402
  5. Dave Angel
    Replies:
    2
    Views:
    2,229
    Dave Angel
    Sep 25, 2009
Loading...

Share This Page