From: khaines@... Date: 2006-08-12T00:05:19+09:00 Subject: Re: Start an external application - How? On Fri, 11 Aug 2006, Jan Svitok wrote: > On Windows, fork in not implemented. :( > For this purpose I mainly use `start "" progname.exe` (note the double > quotes: > if the first parameter has quotes, it's the title of the window. That > means `start "c:\Program Files\Anything.exe" won't start the > program...) start will start program and return, so ruby can > continue... If it helps, I use the following bit of code when I need to platform-independently start an external process within my test suites. It depends on win32/process being available on Windows. Usage is: IWATestSupport.create_process(app_to_start) i.e. IWATestSupport.create_process('webrick.rb') module IWATestSupport def self.create_process(args) @fork_ok = true unless @fork_ok == false pid = nil begin raise NotImplementedError unless @fork_ok unless pid = fork Dir.chdir args[:dir] exec(*args[:cmd]) end rescue NotImplementedError @fork_ok = false begin require 'rubygems' rescue Exception end begin require 'win32/process' rescue LoadError raise "Please install win32-process to run all tests on a Win32 platform. 'gem install win32-process' or http://rubyforge.org/projects/win32utils" end cwd = Dir.pwd Dir.chdir args[:dir] pid = Process.create(:app_name => args[:cmd].join(' ')) Dir.chdir cwd end pid end end Kirk Haines