change windows system path from cygwin python?

G

gry

[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.
 
H

Harlin Seritt

[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
 
J

Jeff Lindholm

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.
 
F

Fredrik Lundh

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>
 
J

Jason Tishler

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
 
G

gry

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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,166
Latest member
DollyBff32
Top