Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Win32 Service: Access Denied when creating service

Reply
Thread Tools

Win32 Service: Access Denied when creating service

 
 
Rajiv Abraham
Guest
Posts: n/a
 
      04-15-2010
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",
assword => "my_pwd" )

but it still did not work.

Thanks,
Rajiv
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Rajiv Abraham
Guest
Posts: n/a
 
      04-15-2010
Rajiv Abraham wrote:
> 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",
> assword => "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

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

 
Reply With Quote
 
 
 
 
Luis Lavena
Guest
Posts: n/a
 
      04-15-2010
On Apr 15, 8:10*am, Rajiv Abraham <(E-Mail Removed)> wrote:
> Rajiv Abraham wrote:
> > 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_ba r_1.rb:9:in
> > `new'
> > * * * * from
> > C:/Users/Rajiv/Documents/NetBeansProjects/MusicClockService/lib/register_ba r_1.rb:9

>
> > I tried changing to:

>
> > svc = Service.new(:service_name =>SERVICE_NAME,
> > * * * * * * * * * :service_start_name => "HOME\\Rajiv",
> > * * * * * * * * * assword => "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


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

--
Luis Lavena
 
Reply With Quote
 
Rajiv Abraham
Guest
Posts: n/a
 
      04-16-2010
Luis Lavena wrote:
> On Apr 15, 8:10´┐Żam, Rajiv Abraham <(E-Mail Removed)> wrote:
>> > Error:
>> > svc = Service.new(:service_name =>SERVICE_NAME,

>> --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


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
Win32-service: error 5: access denied Michael Dichtl Ruby 0 07-11-2007 08:20 AM
403 Forbidden: You were denied access because: Access denied by access control list Southern Kiwi NZ Computing 6 03-19-2006 05:19 AM
Web Service + Anon Access, but getting 401 Access Denied Error Alex Washtell via .NET 247 ASP .Net Web Services 1 04-05-2005 04:57 PM
Access Denied - Network Service vs Local Service mangia ASP .Net Security 3 09-27-2004 09:26 PM



Advertisments