Win32 Service: Access Denied when creating service

Discussion in 'Ruby' started by Rajiv Abraham, Apr 15, 2010.

  1. 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
    --
    Posted via http://www.ruby-forum.com/.
     
    Rajiv Abraham, Apr 15, 2010
    #1
    1. Advertising

  2. 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",
    > :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

    --
    Posted via http://www.ruby-forum.com/.
     
    Rajiv Abraham, Apr 15, 2010
    #2
    1. Advertising

  3. Rajiv Abraham

    Luis Lavena Guest

    On Apr 15, 8:10 am, Rajiv Abraham <> 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",
    > >                   :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


    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
     
    Luis Lavena, Apr 15, 2010
    #3
  4. Luis Lavena wrote:
    > On Apr 15, 8:10�am, Rajiv Abraham <> 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/.
     
    Rajiv Abraham, Apr 16, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wanda
    Replies:
    1
    Views:
    396
    Ariel Popovsky
    Nov 10, 2004
  2. mangia

    Access Denied - Network Service vs Local Service

    mangia, Sep 23, 2004, in forum: ASP .Net Security
    Replies:
    3
    Views:
    250
    Ken Schaefer
    Sep 27, 2004
  3. Alex Washtell via .NET 247

    Web Service + Anon Access, but getting 401 Access Denied Error

    Alex Washtell via .NET 247, Apr 5, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    202
    Mauro Ottaviani [MSFT]
    Apr 5, 2005
  4. Shea Martin
    Replies:
    1
    Views:
    144
    Shea Martin
    Oct 11, 2005
  5. Michael Dichtl

    Win32-service: error 5: access denied

    Michael Dichtl, Jul 11, 2007, in forum: Ruby
    Replies:
    0
    Views:
    153
    Michael Dichtl
    Jul 11, 2007
Loading...

Share This Page