How to set path in Windows NT?
whisper at oz.nospamnet
Wed May 16 19:50:43 CEST 2001
In article <j6j4gtost1j98cqlg5td32ndh176fsktt5 at 4ax.com>,
Wolfgang.Strobl at gmd.de says...
> kc5tja at dolphin.openprojects.net (Samuel A. Falvo II) schrieb am Tue, 15
> May 2001 23:55:26 GMT:
> >Not strictly Python related, but...
> >I've written a utility batch file that I'd like to be executable after
> >installing it on a computer. How can I programmatically set the PATH
> >environment variable to include a directory of my choice, such that the next
> >time the user logs in or runs the command prompt, the variable will be set
> Read and try the following script, and don't forget to repair your path
> afterwards. :-)
> import _winreg
> print "Your environment variables are"
> print "#","name","value","type"
> for i in range(1000):
> print i,n,v,t
> except EnvironmentError:
> print "You have",i,"Environment variables"
> print "Your PATH was "
> path = _winreg.QueryValueEx(y,"path")
> print path
> # Reopen Environemt key a second time, for writing.
> # now append C:\ to the path
saved this as winenv.py. running it got:
[k:/Python21/Projects]% python winenv.py
Traceback (most recent call last):
File "winenv.py", line 3, in ?
WindowsError: [Errno 2] The system cannot find the file specified
More information about the Python-list