[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

win32 service

Brian Scott

4/4/2008 10:53:00 PM

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
--
Posted via http://www.ruby-....

6 Answers

Luis Lavena

4/4/2008 11:20:00 PM

0

On Apr 4, 7:53 pm, Brian Scott <mr.nov...@gmail.com> wrote:
> 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/se...

HTH,
--
Luis Lavena

Brian Scott

4/4/2008 11:56:00 PM

0

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










Luis Lavena wrote:
> On Apr 4, 7:53 pm, Brian Scott <mr.nov...@gmail.com> wrote:
>> Agent\\TBWin32ReportingAgt.exe'
>> 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/se...
>
> HTH,

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

Luis Lavena

4/5/2008 12:02:00 AM

0

On Apr 4, 8:55 pm, Brian Scott <mr.nov...@gmail.com> wrote:
> 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.

--
Luis Lavena

Brian Scott

4/5/2008 12:08:00 AM

0

I tried removing that , before I'll try again

Luis Lavena wrote:
> On Apr 4, 8:55 pm, Brian Scott <mr.nov...@gmail.com> wrote:
>> :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.

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

Brian Scott

4/5/2008 12:12:00 AM

0

It worked

Thank You

Brian Scott wrote:
> I tried removing that , before I'll try again
>
> Luis Lavena wrote:
>> On Apr 4, 8:55 pm, Brian Scott <mr.nov...@gmail.com> wrote:
>>> :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.

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

Daniel Berger

4/5/2008 2:25:00 AM

0

Brian Scott wrote:
> 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