Update: modules Win32::Env and Win32::Env::Path(note: WEP does not broadcast the change) make this code obsolete.
Everyone (I hope) knows that changing environment variables only affects current and (subsequently spawned) child processes and doesn't affect parent or other unrelated processes. But on Windows, when you go through Control Panel to change environment variables, that's exactly what does happen (it changes environment variables in other processes). I had to do a bit of searching to find out how to do this, so just in case you ever need to do this, here it is. Might it be a good idea to wrap this up in a module...maybe Win32::EnvVar??
This program broadcasts to other Win32 processes a message to reload their environment. Other processes do not have to listen to the message. "CMD.EXE" and "PERL.EXE", e.g., do not reload their environment.
Note: There is also Win32::AdminMisc::SetEnvVar(), but it crashed perl when I ran it on Windows XP with ActiveState perl 5.8.4 build 810. Although other functions in the package worked fine.
Updated: Path is a REG_EXPAND_SZ...see GetValue() method in Win32::TieRegistry to see how get the type of other registry values/environment variables if you want a more dynamic solution.
Note: I very nearly used ActiveState's ActiveTcl for this, because it comes with a "broadcast" function in the "registry" package.