win32 service

B

Brian Scott

Hello,

I'm trying to add a application as a service in Windows XP Pro

I'm using the following code grabbed from KirbyBase:

svc = Service.new("localhost")
svc.create_service do |s|
s.service_name = "TBWin32ReportingAgt"
s.binary_path_name = 'C:\\TBWin32\\TB Reporting
Agent\\TBWin32ReportingAgt.exe'
s.display_name = "TBWin32 Reporting Agt"

# This is required for now - bug in win32-service
s.dependencies = []
end
svc.close
puts "TBWin32 Server service installed"

When I run this I get the following:

c:/ruby/lib/ruby/gems/1.8/gems/win32-service-0.6.1-x86-mswin32-60/lib/win32/serv
ice.rb:277:in `initialize': no options provided (ArgumentError)
from s.rb:6:in `new'
from s.rb:6
 
L

Luis Lavena

Hello,

I'm trying to add a application as a service in Windows XP Pro

I'm using the following code grabbed from KirbyBase:

svc = Service.new("localhost")
svc.create_service do |s|
s.service_name = "TBWin32ReportingAgt"
s.binary_path_name = 'C:\\TBWin32\\TB Reporting
Agent\\TBWin32ReportingAgt.exe'
s.display_name = "TBWin32 Reporting Agt"

# This is required for now - bug in win32-service
s.dependencies = []
end
svc.close
puts "TBWin32 Server service installed"

When I run this I get the following:

c:/ruby/lib/ruby/gems/1.8/gems/win32-service-0.6.1-x86-mswin32-60/lib/win32/serv
ice.rb:277:in `initialize': no options provided (ArgumentError)
from s.rb:6:in `new'
from s.rb:6

You're using 0.5 win32-service syntax. with 0.6 you need to construct
everything in inside the new block:

http://rubyforge.org/docman/view.php/85/595/service.html

HTH,
 
B

Brian Scott

If I use the following code:

Service.create('TBWin32Agt', nil,
:service_type => Service::WIN32_OWN_PROCESS,
:description => ' Reporting Agent',
:start_type => Service::AUTO_START,
:error_control => Service::ERROR_NORMAL,
:binary_path_name => 'C:\\TBWin32\\TB Reporting
Agent\\TBWin32ReportingAgt.exe',
:load_order_group => 'Network',
:dependencies => ['W32Time','Schedule'],
:service_start_name => '',
:password => '',
:display_name => 'TBWin32RptAgt',
)

I get "unexpected )" error
 
L

Luis Lavena

If I use the following code:

Service.create('TBWin32Agt', nil,
:service_type => Service::WIN32_OWN_PROCESS,
:description => ' Reporting Agent',
:start_type => Service::AUTO_START,
:error_control => Service::ERROR_NORMAL,
:binary_path_name => 'C:\\TBWin32\\TB Reporting
Agent\\TBWin32ReportingAgt.exe',
:load_order_group => 'Network',
:dependencies => ['W32Time','Schedule'],
:service_start_name => '',
:password => '',
:display_name => 'TBWin32RptAgt',
)

I get "unexpected )" error

That's because there is a ',' before the ) ... a silly typo, just
remove it.
 
B

Brian Scott

I tried removing that , before I'll try again

Luis said:
:dependencies => ['W32Time','Schedule'],
:service_start_name => '',
:password => '',
:display_name => 'TBWin32RptAgt',
)

I get "unexpected )" error

That's because there is a ',' before the ) ... a silly typo, just
remove it.
 
B

Brian Scott

It worked

Thank You

Brian said:
I tried removing that , before I'll try again

Luis said:
:dependencies => ['W32Time','Schedule'],
:service_start_name => '',
:password => '',
:display_name => 'TBWin32RptAgt',
)

I get "unexpected )" error

That's because there is a ',' before the ) ... a silly typo, just
remove it.
 
D

Daniel Berger

Brian said:
If I use the following code:

Service.create('TBWin32Agt', nil,
:service_type => Service::WIN32_OWN_PROCESS,
:description => ' Reporting Agent',
:start_type => Service::AUTO_START,
:error_control => Service::ERROR_NORMAL,
:binary_path_name => 'C:\\TBWin32\\TB Reporting
Agent\\TBWin32ReportingAgt.exe',
:load_order_group => 'Network',
:dependencies => ['W32Time','Schedule'],
:service_start_name => '',
:password => '',
:display_name => 'TBWin32RptAgt',
)

I get "unexpected )" error

You've got a trailing comma after 'TBWin32RptAgt'. Ruby doesn't like that.

Regards,

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top