windows-cmd shell doesn't reflect _winreg changes

haughki hawkeye.parker at autodesk.com
Wed Apr 9 15:08:23 EDT 2003


Many thanks Ben!!




Ben Hutchings <do-not-spam-ben.hutchings at businesswebsoftware.com> wrote in message news:<slrnb8p06l.174.do-not-spam-ben.hutchings at tin.bwsint.com>...
> In article <b6e56f7a.0304021609.521700e6 at posting.google.com>, haughki wrote:
> > hi
> > 
> > i'm using _winreg to 'hard-change' and environmental variable in
> > windows.  the change is 'successful': regedit correctly reflects the
> > changes, and crtl panel > system > properties envronmental vars have
> > been correctly changed.  but, when i start a cmd shell (dos), the
> > shell evironment still reflects the old values until i manually open
> > the env vars cntrl panel and click 'ok'.  anyone?
> 
> This is really a Win32 programming issue rather than a Python one.
> However, I do vaguely remember this one.
> 
> Environmental variables are normally passed to a new process by the
> process that creates it, and they can never be updated from outside
> a process.  The exception to this is that Windows Explorer (and any
> other program that wishes to) will read those initial environment
> variables out of the registry when notified of a change in settings.
> The changes will then be passed on to any program started by Explorer
> afterwards.
> 
> Here's the Python code:
> 
>     import win32con, win32gui
>     win32gui.SendMessage(
>         win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, 0)
> 
> You might want to use SendMessageTimeout instead of SendMessage.




More information about the Python-list mailing list