Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Changing parent process environment variableby cdarke (Prior) |
on Dec 20, 2007 at 21:30 UTC ( [id://658278]=note: print w/replies, xml ) | Need Help?? |
It is not possible for a child process to directly alter the parent's environment block without using some shared memory magic - and that is true whatever the language used, compiled or not. The environment block is set at process creation time and by default is a copy of the parent's. There is no concept of a "global" environment. All this is true on Windows and UNIX. However on Windows, environment variables are also stored in the Registry, either in HKEY_CURRENT_USER\Environment (user variables) or HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment (system variables). So you could use one of the (several) Win32 Perl modules to change the registry. Now the tricky bit: for the parent to pick-up the change you should send a WM_SETTINGCHANGE message. I don't know how to do that from Perl, but there probably is a way. Look at the Win32:: namespace modules. There are easier ways to pass a text string between programs ;-)
In Section
Seekers of Perl Wisdom
|
|