The following code is in a file called run.rb, the idea is to run ruby as a different user so I can do some testing.
require 'rubygems'
require 'win32/process'
domain = 'WORLDWIDE'
user_name = 'user'
password = 'password'
rubyScript = 'ruby test.rb'
Process.create(:command_line => rubyScript, :domain => domain, :with_logon => user_name, :password => password, :close_handles => false)
the contents of test.rb is:
require 'rubygems'
require 'watir'
browser = Watir::IE.new
browser.goto('http://localhost:44001/Users/List')
puts browser.text
when I run 'ruby run.rb' a command shell opens and then closes straight away. Any ideas what I am doing wrong here?