How to start a service with the win32-service gem

Hi
I have install the win32-service 0.6.0 and made some test code just like
these:

require 'rubygems'
require "win32/service"
require "Win32API"
include Win32

begin
srv = Service.new()
srv.binary_path_name = "c:/ruby/bin/ruby " + File.expand_path($0)
srv.create_service{|s|
  s.service_name = "foo"

  s.display_name = "Test_Demo"
  s.service_description = "Greatest Service"
}
srv.configure_service{|serv|
  serv.display_name = "My Service"
  serv.start_type = Service::AUTO_START
  serv.service_type = Service::WIN32_OWN_PROCESS
}
srv.close
rescue
end

class Daemon
  def service_init
    sleep(200)
  end
  def service_main
   system('notepad')
    while running?
      #puts 'the service in running'
      if state == RUNNING
      system('notepad')
      sleep 5
      end
    end
  end
  d = Daemon.new
  d.mainloop
end
the service can be registered but can't to be start.When I try to
run(start) it in the Management Console that I will get the 1053 error
with the service.How can I to rescue the problem.
My OS is Windows XP SP2
Any help will be very grateful.

···

--
Posted via http://www.ruby-forum.com/.