From: Armin Roehrl Date: 2002-12-10T02:35:15+09:00 Subject: Re: Environment variables > How can I set environment variables to a program that I run using > Kernel#system? Hi Mauricio, If you use Unix/Linux I think the normal ENV should do the job. Under Windows it's more tricky. I collected these snipplets that appeared on that list some time ago. # code by Hee-Sob Park - posted here: # http://ruby-talk.com/10006 def system(command) Win32API.new("crtdll", "system", ['P'], 'L').Call(command) end # code by Hee-Sob Park - posted here: # http://ruby-talk.com/10006 def `(command) popen = Win32API.new("crtdll", "_popen", ['P','P'], 'L') pclose = Win32API.new("crtdll", "_pclose", ['L'], 'L') fread = Win32API.new("crtdll", "fread", ['P','L','L','L'], 'L') feof = Win32API.new("crtdll", "feof", ['L'], 'L') saved_stdout = $stdout.clone psBuffer = " " * 128 rBuffer = "" f = popen.Call(command,"r") while feof.Call( f )==0 l = fread.Call( psBuffer,1,128,f ) rBuffer += psBuffer[0..l] end pclose.Call f $stdout.reopen(saved_stdout) rBuffer end