Any ideas folks?
Thanks,
Dan
---------- Forwarded message ----------
From: Kay <serphakay hotmail.com>
Date: Sep 19, 2007 10:52 AM
Subject: win32-service of win32utils
To: djberg96 gmail.com
I'm writing some scripts to programmatically change the user
account
of running a windows service. So I downloaded one of the
windows
utilities, win32-service, and wrote my scripts. However when
I was
trying to use the following scripts to change the name of
the account
of running a windows service
s.configure_service{ |s|
s.start_name = "name of the account"
s.password = "password" # Note that I used plain
text password
}
I was always given some kinds of error messages, which
varied based on
different formats of the account name being used. So
with start_name = "domain_nameuser_name" (using
for escaping and
have tried domain_name with either upper case or lower
case), the
message is "the parameter is incorrect".
with start_name = "domain_nameuser_name" (have
tried domain_name with
either upper case or lower case), the message is "the
account name is
invalid or does not exist, or the password is invalid for
the account
name specified".
with start_name = "user_name domain_name.com", the
message is " the
parameter is incorrect".
with start_name = "user_name another_domain_name.com",
(another_domain_name is a possible domain name for me), the
message is
"the specified domain either does not exist or could
not be
contacted".
with start_name = "user_name", the message is
"the account name is
invalid or does not exist, or the password is invalid for
the account
name specified".
So I'm writing to ask for your suggestions. BTW, do you
think it's
right to use password in plain text? Your help is very
appreciated.
The following is a full script I was using.
base = File.basename(Dir.pwd)
if base == "examples" || base =~ /win32-service/
require "ftools"
Dir.chdir("..") if base ==
"examples"
Dir.mkdir("win32") unless
File.exists?("win32")
File.copy("service.so","win32")
$LOAD_PATH.unshift Dir.pwd
end
require "win32/service"
include Win32
s = Service.new("machine_name")
# Create a new service
if Service.exists?("foo")
Service.delete("foo")
end
s.create_service{ |s|
s.service_name = "foo"
s.binary_path_name =
"C:AutonomyDocumentumFetchOldDocumentumFetchOld.exe&
quot;
s.display_name = "My Foo Service"
}
# Configure a service that already exists
s.configure_service{ |s|
s.start_name = "start_name"
s.password = "password"
}
s.close
Service.start("foo")
Service.pause("foo")
Service.resume("foo")
Service.stop("foo")
Service.delete("foo")
Service.getdisplayname("Schedule") # "Task
Scheduler"
Service.getservicename("ClipBook") #
"ClipSrv"
s = Service.status("ClipSrv")
# Enumerate over all services, inspecting each struct
Service.services{ |s|
p s
puts
}
Thanks!
_______________________________________________
win32utils-devel mailing list
win32utils-devel rubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel
|