[Win32utils-devel] Fwd: win32-service of win32utils

Heesob Park phasis at gmail.com
Wed Sep 19 21:34:59 EDT 2007


Hi,

2007/9/20, Daniel Berger <djberg96 at gmail.com>:
>
> Any ideas folks?
>
> Thanks,
>
> Dan
>
> ---------- Forwarded message ----------
> From: Kay <serphakay at hotmail.com>
> Date: Sep 19, 2007 10:52 AM
> Subject: win32-service of win32utils
> To: djberg96 at 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_name\user_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_name\user_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 at domain_name.com", the message is " the
> parameter is incorrect".
>
>
>
> with start_name = "user_name at 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:\Autonomy\DocumentumFetchOld\DocumentumFetchOld.exe"
>
> 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!


I guess it is due to the "\" character escaping.

start_name = "domain_name\user_name"

should be

 start_name = "domain_name\\user_name"
or
 start_name = 'domain_name\user_name'

Regards,

Park Heesob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20070920/2d40fb6e/attachment.html 


More information about the win32utils-devel mailing list