[Tutor] Re: How to change Windows Environment Variable
dman
dsh8290 at rit.edu
Mon Oct 29 18:05:01 EST 2001
On Thu, Aug 30, 2001 at 08:14:06PM -0400, Ignacio Vazquez-Abrams wrote:
| On Fri, 31 Aug 2001, ??? wrote:
|
| > Dear all,
| >
| > How to change environment variable on Windows NT or 2000 by python?
| >
| > In Visual Basic case can setting as below:
| >
| > Private Declare Function GetEnvironmentVariable Lib "kernel32" _
| > Alias "GetEnvironmentVariableA" (ByVal lpName As String, _
| > ByVal lpBuffer As String, ByVal nSize As Long) As Long
| >
| > Private Declare Function SetEnvironmentVariable Lib "kernel32" _
| > Alias "SetEnvironmentVariableA" (ByVal lpName As String, _
| > ByVal lpValue As String) As Long
| >
| > I will waiting for good news.
| > Thanks.
| > MyeongKi Han
|
| Good news:
|
| There is a GetEnvironmentVariable() function in the win32api module.
|
| Bad news:
|
| There is no SetEnvironmentVariable() function.
See the 'os' module.
>>> import os
>>> print os.putenv.__doc__
putenv(key, value) -> None
Change or add an environment variable.
>>>
The 'os.environ' attribute is a dict containing all the environment
variables.
-D
More information about the Python-list
mailing list