Win32 Service: Access Denied when creating service

R

Rajiv Abraham

Hi,
I am trying to create and register a windows service with the following
code.

require "rubygems"
require "win32/service"
include Win32
svc = Service.new:)service_name => "rajiv_service_name")

Error:
C:/Ruby/lib/ruby/gems/1.8/gems/win32-service-0.7.1-x86-mswin32-60/lib/win32/service.rb:368:in
`initialize': Access is denied. (Win32::Service::Error)
from
C:/Users/Rajiv/Documents/NetBeansProjects/MusicClockService/lib/register_bar_1.rb:9:in
`new'
from
C:/Users/Rajiv/Documents/NetBeansProjects/MusicClockService/lib/register_bar_1.rb:9


I tried changing to:

svc = Service.new:)service_name =>SERVICE_NAME,
:service_start_name => "HOME\\Rajiv",
:password => "my_pwd" )

but it still did not work.

Thanks,
Rajiv
 
R

Rajiv Abraham

Rajiv said:
Hi,
I am trying to create and register a windows service with the following
code.

require "rubygems"
require "win32/service"
include Win32
svc = Service.new:)service_name => "rajiv_service_name")

Error:
C:/Ruby/lib/ruby/gems/1.8/gems/win32-service-0.7.1-x86-mswin32-60/lib/win32/service.rb:368:in
`initialize': Access is denied. (Win32::Service::Error)
from
C:/Users/Rajiv/Documents/NetBeansProjects/MusicClockService/lib/register_bar_1.rb:9:in
`new'
from
C:/Users/Rajiv/Documents/NetBeansProjects/MusicClockService/lib/register_bar_1.rb:9


I tried changing to:

svc = Service.new:)service_name =>SERVICE_NAME,
:service_start_name => "HOME\\Rajiv",
:password => "my_pwd" )

but it still did not work.

Thanks,
Rajiv

Just adding to the previous post, if it helps:
- I installed the win32-services gem using gem install win32-service
--platform=mswin32
- The doc. says that only :service_name is mandatory. So, it is bit
surprising that it does not work
- User Rajiv is Administrator
 
L

Luis Lavena

Just adding to the previous post, if it helps:
- I installed the win32-services gem using gem install win32-service
--platform=mswin32
- The doc. says that only :service_name is mandatory. So, it is bit
surprising that it does not work
- User Rajiv is Administrator

Is the prompt from where are you invoking the ruby script running with
elevated privileges?

On Vista and 7 even when user is Administrator it needs UAC elevation
to properly modify registry related to system
 
R

Rajiv Abraham

Luis said:
Is the prompt from where are you invoking the ruby script running with
elevated privileges?

On Vista and 7 even when user is Administrator it needs UAC elevation
to properly modify registry related to system

Thanks Luis !
I run the file from netbeans 6.8 and you set me on the right path.
Based on your answer, I poked about a bit and found
[http://www.ruby-forum.com/topic/198439#905647] where Philippe Rubyeye
provided an easy alternative(Running Netbeans as administrator).
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top