From: Alan Chen Date: 2005-07-19T04:15:55+09:00 Subject: Re: windows - How to propagate environment variables to the system To get the registry settings having to do with environment to stick without rebooting you also need to broadcast a message to notify processes of the change. Here's my revant code snippet: (Watch the urls in my comments. they may wrap badly) # broadcast a settings change # http://support.microsoft.com/?kbid=104011 the exact issue # WM_SETTINGCHANGE info # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/wm_settingchange.asp # SendMessage info # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesfunctions/sendmessage.asp require 'Win32API' SendMessage = Win32API.new("user32", "SendMessage", ['L', 'L', 'P', 'P'], 'L') HWND_BROADCAST = 0xffff WM_SETTINGCHANGE = 0x001A puts SendMessage.Call(HWND_BROADCAST,WM_SETTINGCHANGE, 0, "Environment") It took me a week of head-scratching to figure out that registry.rb made the right changes, but they weren't being accepted quite correctly - especially when you want to use other Env variables in your definition. e.g. SRCTREE = %HOME%/blah/blah HTH, - alan