Hi Guys,
I desperately need help with this as I can’t understand why it is
working.
I am trying to create windows service using win32/service with a
specific user login. I have provided the username and password correctly
in my ruby script.
Essentially, when i run the script below it successfully creates the
service. But fails to start saying “Logon Failure” message. However,
if I go to the windows service window (services.msc) and right click
service and then go to properties->Log On and enter the same password
and then start the service it all works fine.
Please help if you have ever encounter this before? I do not understand
what is going on. (I am logged in as Adminstrator when I run this
script)
myService.ruby
require “win32/service”
include Win32
Service.create(“MyService”, nil,
:description => “My Ruby Service”,
:start_type => Service::AUTO_START,
:error_control => Service::ERROR_NORMAL,
:binary_path_name => “C:\myService.exe”,
:display_name => “MyService”,
:service_start_name => “domain\myUser”,
:password => “myPass”,
:service_type=> Service::SERVICE_WIN32_OWN_PROCESS
)
Service.start(“MyService”)
Ashish Deepak4 wrote in post #979326:
Hi Guys,
I desperately need help with this as I can’t understand why it is
working.
I am trying to create windows service using win32/service with a
specific user login. I have provided the username and password correctly
in my ruby script.
Essentially, when i run the script below it successfully creates the
service. But fails to start saying “Logon Failure” message. However,
if I go to the windows service window (services.msc) and right click
service and then go to properties->Log On and enter the same password
and then start the service it all works fine.
Please help if you have ever encounter this before? I do not understand
what is going on. (I am logged in as Adminstrator when I run this
script)
myService.ruby
require “win32/service”
include Win32
Service.create(“MyService”, nil,
:description => “My Ruby Service”,
:start_type => Service::AUTO_START,
:error_control => Service::ERROR_NORMAL,
:binary_path_name => “C:\myService.exe”,
:display_name => “MyService”,
:service_start_name => “domain\myUser”,
:password => “myPass”,
:service_type=> Service::SERVICE_WIN32_OWN_PROCESS
)
Service.start(“MyService”)
Found the solution.
You have to grant the user the SeServiceLogonRight permission first
before staring the service.
I did this using ntrights.exe.
Found following pages helpful:
http://www.questionhub.com/ServerFault/197881
http://support.microsoft.com/kb/315276