Page 1 of 1

How to send notification messages with COM?

Posted: Tue Oct 16, 2007 8:18 pm
by Ambush Commander
I'm using the spiffy COM interface to read and write values from the registry:

Code: Select all

$shell = new COM('WScript.Shell');
$shell->RegWrite(
    $ureg_key . 'Path',  $user_path_string, 'REG_EXPAND_SZ'
);
For this particular case, I'm modifying the registry values that correspond to Window's environment variables. This lets me change my persistent environment variables without using setx or setenv.

Unfortunately, even though the registry is properly written to, it doesn't seem like Windows realizes that the environment has changed (not even when I reboot explorer). Apparently, I have to send a message to all the Windows in order to notify them of the change. I, unfortunately, have no idea how to do this with COM. Any ideas?

I'm currently working around this by executing an external setenv utility, but a built in PHP solution would be ideal.