From: Phillip Gawlowski Date: 2009-12-19T03:49:39+09:00 Subject: Re: Setting Windows Enviroment in Ruby Script On 18.12.2009 18:24, jackster the jackle wrote: > I need to set the following windows environment variable at the > beginning of my script: > > set http_proxy=http://10.1.1.1:8080 > > This works from the command line if I run this command from the CLI > right before I run my script but when I try to shell out and the run > command like this from my ruby script: > > `set http_proxy=http://10.1.1.1:8080` > > The environmental variable never gets set. > > What is the best way to set an environmental variable in Windows from > ruby? "set" only sets a variable for the process that invokes "set": Quoth Microsoft: "Use the set command to create, change, delete, or display environment variables. The set command alters variables in the current shell environment only."[0] http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true So, your variable gets set, but since the cmd shell expires, it takes the environment variable with it. You could try setting the variable in the Registry, but I advise against it (not a robust solution for something that is intended to be temporary, and it needs administration privileges). You could define a Constant in Ruby, though, if only your Ruby script needs it, like so: HTTP_PROXY = your_proxy_ip_address -- Phillip Gawlowski