This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nobody
Recipients
Date 2001-09-21.10:05:38
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content

I used function KERNEL32::SetEnvironmentVariableA 
via Dynawrap.dll from
http://cwashington.netreach.net/main_site/
downloads/default.asp?topic=a-m
to add an new entry.

Then I tested the result with a scripting host 
component and the new entry was shown. But not working 
was this:

reload(os)
os.environ


PythonWin 2.1 (#15, Jun 18 2001, 21:42:28) [MSC 32 bit 
(Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond 
(MarkH@ActiveState.com) - see 'Help/About PythonWin' 
for further copyright information.
>>> import os
>>> os.environ
{'SNDSCAPE': 'C:\\WINDOWS', 'CMDLINE': 'WIN', 'PATH': '
C:\\PROGRAMME\\PYTHON21
\\;C:\\WINDOWS;C:\\WINDOWS\\COMMAND', 'TEMP': 'C:\\WIND
OWS\\TEMP', 'COMSPEC': 'C:\\WINDOWS\\COMMAND.COM', 'PRO
MPT': '$p$g', 'WINBOOTDIR': 'C:\\WINDOWS', 'WINDIR': 'C
:\\WINDOWS', 'TMP': 'C:\\WINDOWS\\TEMP'}
>>> 
>>> from win32com.client import Dispatch
>>> dw = Dispatch("DynamicWrapper")
>>> dw.Register
("KERNEL32.DLL", "SetEnvironmentVariableA", "i=ss", "f=
s", "r=l")
1
>>> dw.SetEnvironmentVariableA
("MyNewEntry", "MyNewValue")
1
>>> reload(os)
<module 'os' from 'c:\programme\python21\lib\os.pyc'>
>>> os.environ
{'SNDSCAPE': 'C:\\WINDOWS', 'CMDLINE': 'WIN', 'PATH': '
C:\\PROGRAMME\\PYTHON21
\\;C:\\WINDOWS;C:\\WINDOWS\\COMMAND', 'TEMP': 'C:\\WIND
OWS\\TEMP', 'COMSPEC': 'C:\\WINDOWS\\COMMAND.COM', 'PRO
MPT': '$p$g', 'WINBOOTDIR': 'C:\\WINDOWS', 'WINDIR': 'C
:\\WINDOWS', 'TMP': 'C:\\WINDOWS\\TEMP'}
>>> 
>>> sh = Dispatch("WScript.Shell")
>>> for string in sh.Environment._NewEnum():
... 	print string
... 	
TMP=C:\WINDOWS\TEMP
TEMP=C:\WINDOWS\TEMP
PROMPT=$p$g
winbootdir=C:\WINDOWS
COMSPEC=C:\WINDOWS\COMMAND.COM
PATH=C:\PROGRAMME\PYTHON21
\;C:\WINDOWS;C:\WINDOWS\COMMAND
CMDLINE=WIN
windir=C:\WINDOWS
SNDSCAPE=C:\WINDOWS
MYNEWENTRY=MyNewValue
>>> 
History
Date User Action Args
2007-08-23 13:56:29adminlinkissue463506 messages
2007-08-23 13:56:29admincreate