win32-service 0.6.1-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,217 @@
1
+ == 0.6.1 - 1-Jan-2008
2
+ * The Service.services method now handles the scenario where a particular
3
+ service may still exist, but its underlying registry entry has been deleted.
4
+ In this case, most ServiceInfo struct members are set to nil and a warning
5
+ is issued.
6
+ * RDoc updates.
7
+
8
+ == 0.6.0 - 25-Nov-2007
9
+ * The Service control class is now pure Ruby. The Daemon class is still C,
10
+ however. That may change in the future. This means the windows-pr
11
+ library is now a prerequisite.
12
+ * The Service.new method has been altered in a way that is not backwards
13
+ compatible. It is now the same as Service.create.
14
+ * The Service.start method now properly handles arguments to the
15
+ Daemon#service_main method.
16
+ * The Daemon source code is now separate from the Service control class
17
+ source code. That means you must require them separately, as needed.
18
+ * The Daemon class should be much more responsive to service events now,
19
+ especially service_stop. Many thanks go to Kevin Burge for the patch.
20
+ * Added the Daemon.mainloop method as a shortcut for Daemon.new.mainloop.
21
+ * The Daemon class now redirects STDIN, STDOUT and STDERR to the NUL device
22
+ if they're still associated with a terminal when the service starts. This
23
+ should help prevent Errno::EBADF errors.
24
+ * The Service.services class method now supports the group parameter for
25
+ versions of Ruby built with older compilers, i.e. it will now work with
26
+ the one-click Ruby installer.
27
+ * The Service.getdisplayname method was changed to Service.get_display_name.
28
+ An alias has been provided for backwards compatibility.
29
+ * The Service.getservicename method was changed to Service.get_service_name.
30
+ An alias has been provided for backwards compatibility.
31
+ * Added the Service.config_info method.
32
+ * The Service.create and Service.configure methods now allow you to set
33
+ failure actions, failure commands, and reset/retry periods.
34
+ * Improved test suite.
35
+ * Changed 'tdaemon.rb', 'tdaemon_ctl.rb' and 'service_test.rb' to
36
+ 'demo_daemon.rb', 'demo_daemon_ctl.rb' and 'demo_services.rb', respectively.
37
+ * Some refactoring and updates to the demo daemon and demo daemon controller
38
+ examples.
39
+ * The Win32Service struct is now ServiceInfo.
40
+ * ServiceError is now Service::Error.
41
+ * DaemonError is now Daemon::Error.
42
+ * Some documentation improvements, corrections and updates.
43
+
44
+ == 0.5.2 - 25-Nov-2006
45
+ * Fixed a bug in the Daemon class where the service event handling methods
46
+ (most notably service_stop) did not work properly due to thread blocking
47
+ issues. Many thanks go to Patrick Hurley for the patch.
48
+ * Added the Daemon#running? method as helper method for your service_main
49
+ method.
50
+ * The 'interactive?' struct member is now just 'interactive'. This was
51
+ supposed to have been in the last release but was somehow missed. Sorry.
52
+ * Scrapped the old daemon_test.rb file and split it into two new files -
53
+ tdaemon.rb and tdaemon_ctl.rb. In the process a few bugs were fixed.
54
+ * Added a gemspec.
55
+ * Documentation and test suite updates.
56
+
57
+ == 0.5.1 - 18-Jun-2006
58
+ * Added the Service.open method.
59
+ * The Service.new method now accepts a block, and automatically closes itself
60
+ at the end of the block.
61
+ * Fixed in a bug in the Service.create method where setting dependencies
62
+ was not working properly. Thanks go to Scott Harper for the spot.
63
+ * The 'interactive?' struct member is now just 'interactive' since Ruby no
64
+ longer supports question marks in struct member names. UGH.
65
+ * The block for Service#configure_service is no longer optional.
66
+ * Replaced ClipSrv with W32Time for most of the test methods in tc_service.rb
67
+ because it had a dependency that is disabled on most systems.
68
+ * Added a tweak to the extconf.rb file to help with the test suite.
69
+ * Some documentation updates and corrections.
70
+
71
+ == 0.5.0 - 26-Nov-2005
72
+ * Added a service_init hook, and (internally) altered the way the service
73
+ starts. This was done to deal with services that need to perform any
74
+ initialization in the Daemon itself before the service starts. Previously
75
+ this would result in the service timing out during startup.
76
+
77
+ Thanks go to Jamey Cribbs for spotting the problem.
78
+
79
+ * Modified the Daemon example, adding a service_init hook that does about 10
80
+ seconds worth of initialization before finally starting. See the comments
81
+ in examples\daemon_test.rb for more information.
82
+ * Minor test and README changes.
83
+
84
+ == 0.4.6 - 24-May-2005
85
+ * Fixed an initialization bug that could cause Daemons to fail unless the
86
+ win32-service package was the last package require'd.
87
+ * Altered the Service.start method. It now takes any number of arguments
88
+ (after the service and host name). These arguments are passed to the
89
+ service's Service_Main() function.
90
+ * The Service.services method now returns an Array of ServiceStruct's in
91
+ non-block form.
92
+ * The Service.start, Service.pause, Service.resume, Service.stop and
93
+ Service.delete methods now return the class (self), not 'true'.
94
+ * Added the ability to add or configure the service description in
95
+ Service#create_service or Service#configure, respectively.
96
+ * Fixed a bug in the Service.start method where false positives could result.
97
+ * Updated the ServiceStatus struct to include pid and service_flags on Win2k
98
+ or later.
99
+ * Unicode is now the default setting as far as internal string handling. It
100
+ will still work fine with 'regular' text.
101
+ * Added safe string handling for string input values.
102
+ * Added rdoc comments into the C source.
103
+ * Made the service.txt and daemon.txt files rdoc friendly.
104
+ * Removed the service.rd and daemon.rd files. If you want html documentation,
105
+ run rdoc over the service.txt and daemon.txt files.
106
+ * The dreaded "code cleanup".
107
+
108
+ == 0.4.5 - 28-Feb-2005
109
+ * Fixed an accessor bug in Service#create. Thanks go to Nathaniel Talbott
110
+ for the spot.
111
+ * Eliminated a warning that appeared starting in Ruby 1.8.2 regarding Struct
112
+ redefinitions.
113
+ * Moved 'examples' directory to toplevel directory.
114
+ * Deleted the 'test2.rb' example. This was supplanted by the 'daemon_test.rb'
115
+ script.
116
+ * Renamed the 'test.rb' file to 'services_test.rb'.
117
+ * Made this document rdoc friendly.
118
+
119
+ == 0.4.4 - 27-Aug-2004
120
+ * Modified the Service class to use the newer allocation framework. The
121
+ Daemon class already used this, hence no major version bump.
122
+ * Fixed in a bug in the create_service() method with regards to the
123
+ 'dependencies' option and null arguments (you no longer need to specify
124
+ an empty array).
125
+
126
+ == 0.4.3 - 14-Aug-2004
127
+ * Fixed the Daemon class by adding back the constants it needed in order to
128
+ run. I accidentally broke this when I changed the Daemon class from being
129
+ a subclass of Service to being its own class.
130
+ * Added a separate test suite for the Daemon class, tc_daemon.rb, to help
131
+ me from making that mistake ever again. :)
132
+ * Updated the daemon_test.rb script a bit to report error messages should
133
+ any occur.
134
+ * Minor doc updates
135
+
136
+ == 0.4.2 - 10-Jul-2004
137
+ * The Daemon class is no longer a subclass of Service.
138
+ * Added the 'pid' and 'service_flags' struct members to the Win32Service
139
+ struct. These members are only available to folks using Windows 2000 or
140
+ later and who compile with VC++ 7.0 or later (including the .NET SDK).
141
+ * The Service.services method now accepts a group name as an optional third
142
+ argument. Again, you must be using Windows 2000 or later and compile with
143
+ VC++ 7.0 or later (including the .NET SDK).
144
+ * The deprecated STR2CSTR() functions were replaced with StringValuePtr().
145
+ This also means that as of this version, win32-service requires Ruby
146
+ 1.8.0 or greater.
147
+ * Moved the sample programs to doc/examples
148
+ * Removed the .html files under /doc. You can generate that on your own if
149
+ you like.
150
+
151
+ == 0.4.1 - 14-Mar-2004
152
+ * Added the exists? class method and corresponding test suite additions.
153
+ * Pushed the ServiceError and DaemonError classes under the Win32 module.
154
+ * Normalized tc_service.rb so that it can be run outside of the test directory
155
+ more easily.
156
+
157
+ == 0.4.0 - 9-Feb-2004
158
+ * Changed "worker" method to "service_main" method.
159
+ * Added event hooks for stop, pause, resume, etc. See the documentation for
160
+ further details. (Thanks Park Heesob)
161
+ * Some of the Daemon functions were raising ServiceError. They have been
162
+ changed to DaemonError.
163
+ * Updated the daemon_test.rb file to use the new event hooks.
164
+ * Documentation additions and updates.
165
+
166
+ == 0.3.0 - 31-Jan-2004
167
+ * Added a Daemon subclass. This allows you to run Ruby programs as a service.
168
+ Please see the documentation for more details. (Thanks Park Heesob). This
169
+ should be considered an ALPHA release.
170
+ * The Win32ServiceError class has been renamed to just ServiceError. I felt
171
+ the "Win32" was redundant, given that it's already under the Win32 module.
172
+ * In some cases a bogus error description was being returned because the
173
+ GetLastError() function was being called too late. This has been fixed.
174
+ (Thanks Park Heesob).
175
+ * The explicit garbage collection has been removed because what I thought was
176
+ a memory leak was not, in fact, a memory leak. In addition, it was hurting
177
+ performance badly.
178
+ * The "\r\n" is now automatically stripped from error messages. This was
179
+ causing slightly garbled error messages. (Thanks Park Heesob).
180
+ * Added explicit closing of the Service Control Manager handle in the
181
+ services() function for those rare cases where it may fail while reading
182
+ service information.
183
+ * Made some of the error strings a bit more descriptive.
184
+ * Test suite and documentation additions, including a sample daemon program
185
+ in the test directory called "daemon_test.rb".
186
+
187
+ == 0.2.2 - 15-Jan-2004
188
+ * Fixed a mistake in the service_init declaration within Init_service().
189
+ * Fixed bug in the service_init function with regards to desired access.
190
+ * Modified service_free() function to explicitly set the hSCManager handle
191
+ to NULL and modified the service_close() method to test hSCManager handle
192
+ for NULL value. This should eliminate accidentally trying to close an
193
+ already closed handle, which may have happened as the result of a free()
194
+ call. (Thanks Park Heesob).
195
+ * Added explicit garbage collection in Service.services() method.
196
+ * More explicit about closing open HANDLE's when error conditions arise.
197
+
198
+ == 0.2.1 - 2-Nov-2003
199
+ * Made the exported less redundant and less verbose, e.g.
200
+ Service::SERVICE_DISABLED is now just Service::DISABLED. The same is true
201
+ for the service control constants, i.e. the 'SC_' has been removed.
202
+ * Corresponding test suite changes.
203
+
204
+ == 0.2.0 - 16-Oct-2003
205
+ * The constructor has been changed. It now only takes a machine name and a
206
+ desired access for arguments. The keyword arguments are now part of the
207
+ create_service method() and only in block form. See the documentation for
208
+ more details.
209
+ * Added a configure_service() and close() instance methods.
210
+ * Added several new constants to allow finer control over created and
211
+ configured services.
212
+ * Added Win32ServiceError as an exception. All failures now raise this
213
+ error instead of a vanilla StandardError.
214
+ * Moved some common code into the service.h file.
215
+
216
+ == 0.1.0 - 10-Oct-2003
217
+ - Initial release
data/MANIFEST ADDED
@@ -0,0 +1,18 @@
1
+ * MANIFEST
2
+ * CHANGES
3
+ * README
4
+ * Rakefile
5
+ * win32-service.gemspec
6
+ * doc/daemon.txt
7
+ * doc/service.txt
8
+ * ext/extconf.rb
9
+ * ext/win32/daemonc.c
10
+ * examples/demo_daemon.rb
11
+ * examples/demo_daemon_ctl.rb
12
+ * examples/demo_services.rb
13
+ * lib/win32/service.rb
14
+ * test/tc_daemon.rb
15
+ * test/tc_service_create.rb
16
+ * test/tc_service_info.rb
17
+ * test/tc_service_status.rb
18
+ * test/tc_service.rb
data/README ADDED
@@ -0,0 +1,44 @@
1
+ = Description
2
+ The win32-service library allows you to control or create MS Windows services.
3
+
4
+ = Installation
5
+ rake test (optional)
6
+ rake install
7
+
8
+ = Documentation
9
+ Please see the documentation in the 'doc' directory, or the gem documentation
10
+ that was installed when you installed this library as a gem.
11
+
12
+ = Possible errors
13
+ * Service.delete causes "Unable to delete: The specified service has
14
+ been marked for deletion."
15
+
16
+ This can be caused by two things. Either you attempted to delete a running
17
+ service without stopping it first, or you have the Services administrative
18
+ tool (GUI) open. The solution is to first stop the service if it's running
19
+ and close the Services GUI admin tool before deleting.
20
+
21
+ * Service.start causes, "The service did not respond to the start or control
22
+ request in a timely fashion."
23
+
24
+ The best way to debug your services is to wrap your entire Daemon subclass
25
+ in a begin/end block and send error messages to a file. That should give a
26
+ good clue as to the nature of the problem. The most probable culprits are:
27
+
28
+ * You've tried to require a library that's not in your $LOAD_PATH. Make sure
29
+ that your require statements are inside the begin/rescue block so that you can
30
+ easily find those mistakes.
31
+
32
+ * Your have a bad binary path name. Be sure to use an absolute path name for
33
+ the binary path name, including the full path to the Ruby interpreter, e.g.
34
+ 'c:\ruby\bin\ruby' instead of just 'ruby'.
35
+
36
+ * You've got a syntax error in your code somewhere.
37
+
38
+ = Possible test failures
39
+ The 'test_service_start_stop' test in the tc_service.rb file may fail. This
40
+ will happen if your W32Time service isn't running.
41
+
42
+ = Future Plans
43
+ * Pure Ruby Daemon class
44
+ * Add service_session_change hook
data/doc/daemon.txt ADDED
@@ -0,0 +1,155 @@
1
+ = Description
2
+ The Daemon class is a wrapper class that allows you to run your code as a
3
+ Windows service.
4
+
5
+ = Synopsis
6
+ class Daemon
7
+ def service_main
8
+ while running?
9
+ sleep 3
10
+ File.open("c:\\test.log","a+"){ |f| f.puts "service is running" }
11
+ end
12
+ end
13
+ end
14
+
15
+ Daemon.mainloop
16
+
17
+ = Class Methods
18
+ Daemon.mainloop
19
+ This is the method that actually puts your code into a loop and allows it
20
+ to run as a service. The code that is actually run while in the mainloop
21
+ is what you defined in the Daemon#service_main method.
22
+
23
+ = Instance Methods
24
+ Daemon#running?
25
+ Returns whether or not the daemon is running. This is just a shortcut
26
+ for checking if the state is RUNNING, PAUSED or IDLE.
27
+
28
+ This is typically used within your service_main method. See the
29
+ demo_daemon.rb file in the 'examples' directory for an example of how it's
30
+ used in practice.
31
+
32
+ Daemon#service_init
33
+ Any code defined defined within this method occurs before service_main is
34
+ reached. Any initialization code that takes more than two seconds to
35
+ execute should be placed here. Otherwise, your service may timeout when
36
+ you try to start it.
37
+
38
+ Daemon#service_main(*args)
39
+ You are expected to define your own service_main() method. The code
40
+ defined in this method is the code that will run while running as a
41
+ service.
42
+
43
+ Any +args+ passed to Service.start are passed to this method.
44
+
45
+ Daemon#state
46
+ Returns the current state of the Daemon. For a list of valid states, see
47
+ the Constants section below.
48
+
49
+ = Signal Event Hooks
50
+ These methods are called if defined within your Daemon class, and the
51
+ appropriate signal is received by your service.
52
+
53
+ Daemon#service_stop
54
+ Called if the service receives a SERVICE_CONTROL_STOP signal. This is
55
+ what the Service.stop() method sends.
56
+
57
+ Daemon#service_pause
58
+ Called if the service receives a SERVICE_CONTROL_PAUSE signal. This is
59
+ what the Service.pause() method sends.
60
+
61
+ Daemon#service_resume
62
+ Called if the service receives a SERVICE_CONTROL_CONTINUE signal. This
63
+ is what the Service.resume() method sends.
64
+
65
+ Daemon#service_interrogate
66
+ Called if the service receives a SERVICE_CONTROL_INTERROGATE signal. This
67
+ notifies a service that it should report its current status information to
68
+ the service control manager.
69
+
70
+ Daemon#service_shutdown
71
+ Called if the service receives a SERVICE_CONTROL_SHUTDOWN signal.
72
+
73
+ Daemon#service_netbindadd
74
+ Called if the service receives a SERVICE_CONTROL_NETBINDADD signal. This
75
+ notifies a network service that there is a new component for binding.
76
+
77
+ Daemon#service_netbinddisable
78
+ Called if the service receives a SERVICE_CONTROL_NETBINDDISABLE signal.
79
+ This notifies a network service that one of its bindings has been
80
+ disabled.
81
+
82
+ Daemon#service_netbindenable
83
+ Called if the service receives a SERVICE_CONTROL_NETBINDENABLE signal.
84
+ This Notifies a network service that a disabled binding has been enabled.
85
+
86
+ Daemon#service_netbindremove
87
+ Called if the service receives a SERVICE_CONTROL_NETBINDREMOVE signal.
88
+ This notifies a network service that that a component for binding has
89
+ been removed.
90
+
91
+ Daemon#service_paramchange
92
+ Called if the service receives a SERVICE_CONTROL_PARAMCHANGE signal.
93
+ This notifies a service that its startup parameters have changed.
94
+
95
+ = Constants
96
+
97
+ === Service state constants
98
+ Daemon::CONTINUE_PENDING
99
+ The service continue is pending.
100
+
101
+ Daemon::PAUSE_PENDING
102
+ The service pause is pending.
103
+
104
+ Daemon::PAUSED
105
+ The service is paused (but not STOPPED).
106
+
107
+ Daemon::RUNNING
108
+ The service is running.
109
+
110
+ Daemon::START_PENDING
111
+ The service is starting (but is not yet in a RUNNING state).
112
+
113
+ Daemon::STOP_PENDING
114
+ The service is stopping (but is not yet in a STOPPED state).
115
+
116
+ Daemon::STOPPED
117
+ The service is not running.
118
+
119
+ Daemon::IDLE
120
+ The service is running, in an idle state. This is a custom state that
121
+ we added that gets around a thread blocking issue.
122
+
123
+ = Notes
124
+ You must create a service before you can actually run it. Look in the
125
+ examples directory for the files 'demo_daemon.rb' and 'demodaemon_ctl.rb'.
126
+ They're small and straightforward examples of how to control, install and
127
+ setup your own Daemon.
128
+
129
+ = Known Bugs
130
+ None known. Please report any bugs you find on the Bug tracker at
131
+ http://rubyforge.org/projects/win32utils.
132
+
133
+ = Future Plans
134
+ Suggestions welcome. Please log them on the Feature Request tracker at
135
+ http://rubyforge.org/projects/win32utils
136
+
137
+ = Acknowledgements
138
+ Many thanks go to Patrick Hurley for providing the fix for the thread
139
+ blocking issue. Thanks also go to Kevin Burge for his patch that solved
140
+ service responsiveness issues.
141
+
142
+ = Copyright
143
+ (C) 2003-2008 Daniel J. Berger, All Rights Reserved
144
+
145
+ = License
146
+ Ruby's
147
+
148
+ = Warranty
149
+ This package is provided "as is" and without any express or
150
+ implied warranties, including, without limitation, the implied
151
+ warranties of merchantability and fitness for a particular purpose.
152
+
153
+ = Author(s)
154
+ * Daniel J. Berger
155
+ * Park Heesob
data/doc/service.txt ADDED
@@ -0,0 +1,365 @@
1
+ = Description
2
+ An interface for MS Windows Services.
3
+
4
+ = Prerequisites
5
+ Ruby 1.8.0 or later.
6
+
7
+ This package is only supported for the Windows NT family of operating
8
+ systems, e.g. 2000, XP, 2003, etc. It is NOT supported (and won't
9
+ work) for any version of DOS or Windows 95/98/ME. It is also not
10
+ supported on NT 4, as that platform is defunct.
11
+
12
+ It should work on Windows XP Home, but is not officially supported for
13
+ that platform.
14
+
15
+ = Synopsis
16
+ require "win32/service"
17
+ include Win32
18
+
19
+ # Create a new service
20
+ Service.create('some_service', nil,
21
+ :service_type => Service::WIN32_OWN_PROCESS,
22
+ :description => 'A custom service I wrote just for fun'
23
+ :start_type => Service::AUTO_START,
24
+ :error_control => Service::ERROR_NORMAL,
25
+ :binary_path_name => 'C:\path\to\some_service.exe',
26
+ :load_order_group => 'Network',
27
+ :dependencies => ['W32Time','Schedule']
28
+ :service_start_name => 'SomeDomain\\User',
29
+ :password => 'XXXXXXX',
30
+ :display_name => 'This is some service',
31
+ )
32
+
33
+ # Configure a service that already exists
34
+ Service.configure(:display_name => "My Bar Service")
35
+
36
+ Service.start("foo")
37
+ Service.pause("foo")
38
+ Service.resume("foo")
39
+ Service.stop("foo")
40
+
41
+ Service.delete("foo")
42
+
43
+ Service.get_display_name("Schedule") # "Task Scheduler"
44
+ Service.get_service_name("ClipBook") # "ClipSrv"
45
+
46
+ Service.status('W32Time') => <struct Struct::ServiceStatus ...>
47
+
48
+ # Enumerate over all services, inspecting each struct
49
+ Service.services{ |s|
50
+ p s
51
+ puts
52
+ }
53
+
54
+ = Class Methods
55
+ Service.new(service_name, host=nil, options={})
56
+ Creates a new service with +service_name+ on +host+, or the local host
57
+ if no host is specified. The +options+ parameter is a hash that can
58
+ contain any of the following parameters, and their default values:
59
+
60
+ * display_name => service_name
61
+ * desired_access => Service::ALL_ACCESS
62
+ * service_type => Service::WIN32_OWN_PROCESS | Service::INTERACTIVE_PROCESS
63
+ * start_type => Service::DEMAND_START
64
+ * error_control => Service::ERROR_NORMAL
65
+ * binary_path_name => nil
66
+ * load_order_group => nil
67
+ * dependencies => nil
68
+ * service_start_name => nil
69
+ * password => nil
70
+ * description => nil
71
+
72
+ Service.configure(service_name, host=nil, options={})
73
+ Configures the named +service_name+ on +host+, or the local host if no
74
+ host is specified. The +options+ parameter is a hash that can contain any
75
+ of the following parameters:
76
+
77
+ * service_type
78
+ * start_type
79
+ * error_control
80
+ * binary_path_name
81
+ * load_order_group
82
+ * dependencies
83
+ * service_start_name
84
+ * password (used with service_start_name)
85
+ * display_name
86
+ * description
87
+
88
+ Service.config_info(service, host=nil)
89
+ Returns a ServiceConfigInfo struct containing the configuration information
90
+ about +service+ on +host+, or the local host if no host is specified.
91
+
92
+ Service.create
93
+ Alias for Service.new
94
+
95
+ Service.delete(service, host=nil)
96
+ Deletes the specified +service+ on +host+. If no host is given,
97
+ then it deletes it on the local machine.
98
+
99
+ Service.exists?(service)
100
+ Returns true if the specified service exists, false otherwise.
101
+
102
+ Service.pause(service, host=nil)
103
+ Pauses the specified +service+ on +host+, or the local machine if
104
+ no host is provided.
105
+
106
+ Service.resume(service, host=nil)
107
+ Resumes the specified +service+ on +host+, or the local machine if
108
+ no host is specified.
109
+
110
+ Service.services(host=nil, group=nil){ |struct| ... }
111
+ Enumerates over a list of service types on host, or the local
112
+ machine if no host is specified, yielding a Win32Service struct for each
113
+ service.
114
+
115
+ If a 'group' is specified, then only those services that belong to
116
+ that group are enumerated. If an empty string is provided, then only
117
+ services that do not belong to any group are enumerated. If this parameter
118
+ is nil, group membership is ignored and all services are enumerated.
119
+
120
+ The 'group' option is only available on Windows 2000 or later, and only
121
+ if compiled with VC++ 7.0 or later, or the .NET SDK. The Win32Service
122
+ struct contains the following members:
123
+
124
+ * service_name
125
+ * display_name
126
+ * service_type
127
+ * current_state
128
+ * controls_accepted
129
+ * win32_exit_code
130
+ * service_specific_exit_code
131
+ * check_point
132
+ * wait_hint
133
+ * binary_path_name
134
+ * start_type
135
+ * error_control
136
+ * load_order_group
137
+ * tag_id
138
+ * start_name
139
+ * dependencies
140
+ * description
141
+ * interactive?
142
+ * pid (Win2k or later)
143
+ * service_flags (Win2k or later)
144
+
145
+ Note that the 'pid' and 'service_flags' members are only available on
146
+ Windows 2000 or later, and only if built with VC++ 7.0 or later (or the
147
+ .NET SDK).
148
+
149
+ Service.start(service, host=nil, *args)
150
+ Starts the specified +service+ on +host+, or the local machine if no
151
+ host is specified. Any +args+ passed here are passed as start parameters
152
+ to the service.
153
+
154
+ Service.status(service)
155
+ Returns a Win32ServiceStatus struct for the specified service (or
156
+ raises a Win32::ServiceError if not found). The Win32ServiceStatus
157
+ struct contains the following members.
158
+
159
+ * service_type
160
+ * current_state
161
+ * controls_accepted
162
+ * win32_exit_code
163
+ * service_specific_exit_code
164
+ * check_point
165
+ * wait_hint
166
+ * interactive?
167
+
168
+ Service.stop(service, host=nil)
169
+ Stops the specified +service+ on +host+, or the local machine if no
170
+ host is specified.
171
+
172
+ = Create and configure options
173
+ binary_path_name
174
+ The binary to be used for the service. The path must be the fully
175
+ qualified path name. A path that contains a space must be quoted so that
176
+ it is correctly interpreted. The path may also include arguments to the
177
+ service entry point (typically the 'main' function).
178
+
179
+ dependencies
180
+ Any dependencies the service has in order to run. This can be a string
181
+ or an array of strings.
182
+
183
+ description
184
+ A text string describing the service.
185
+
186
+ display_name
187
+ The display name to be used by user interface programs to identify the
188
+ service. The string has a maximum length of 256 characters. Case
189
+ sensitivity is preserved.
190
+
191
+ The default is to set the display name to the same string as the
192
+ service name.
193
+
194
+ error_control
195
+ The error control for the service. The default is Service::ERROR_NORMAL.
196
+
197
+ See the "Error Control Contants" section for available options and their
198
+ meanings.
199
+
200
+ load_order_group
201
+ The load order group, a string that names the load ordering group of
202
+ which this service is a member. The default is nil.
203
+
204
+ password
205
+ Sets the passsword to the account name specified in the Service#start_name
206
+ method. By default, this value is set to nil, which is appropriate if
207
+ the account has no password or if the service runs in the
208
+ 'LocalService', 'NetworkService', or 'LocalSystem' account.
209
+
210
+ Note that passwords are ignored for driver services.
211
+
212
+ service_name
213
+ The service name for the service. This value must be set in order
214
+ to create a service. The string has a maximum length of 256 characters.
215
+
216
+ service_type
217
+ The service type for the service. The default is
218
+ Service::WIN32_OWN_PROCESS | Service::INTERACTIVE_PROCESS.
219
+
220
+ See the "Service Type Contants" section for available options and their
221
+ meanings.
222
+
223
+ start_name
224
+ Sets the name of the account under which the service should run.
225
+ By default the 'LocalSystem' account is used.
226
+
227
+ start_type
228
+ The start type for the service. The default is Service::DEMAND_START.
229
+
230
+ See the "Start Type Contants" section for available options and their
231
+ meanings.
232
+
233
+ = Constants
234
+
235
+ === Standard Constants
236
+ VERSION
237
+ The current version number of this package, returned as a string.
238
+
239
+ === Desired Access Constants
240
+ Service::MANAGER_ALL_ACCESS
241
+ Includes STANDARD_RIGHTS_REQUIRED, in addition to all access rights
242
+ in the table.
243
+
244
+ Service::MANAGER_CREATE_SERVICE
245
+ Required to call the CreateService function to create a service object
246
+ and add it to the database.
247
+
248
+ Service::MANAGER_CONNECT
249
+ Required to connect to the service control manager.
250
+
251
+ Service::MANAGER_ENUMERATE_SERVICE
252
+ Required to call the EnumServicesStatus function to list the services
253
+ that are in the database.
254
+
255
+ Service::MANAGER_LOCK
256
+ Required to call the LockServiceDatabase function to acquire a lock on the
257
+ database.
258
+
259
+ Service::MANAGER_BOOT_CONFIG
260
+ Required to call the NotifyBootConfigStatus() (internal) function. Not
261
+ defined with all compilers.
262
+
263
+ Service::MANAGER_QUERY_LOCK_STATUS
264
+ Required to call the QueryServiceLockStatus() (internal) function to
265
+ retrieve the lock status information for the database.
266
+
267
+ === Service Type Constants
268
+ Service::FILE_SYSTEM_DRIVER
269
+ File system driver service.
270
+
271
+ Service::KERNEL_DRIVER
272
+ Driver service.
273
+
274
+ Service::WIN32_OWN_PROCESS
275
+ Service that runs in its own process.
276
+
277
+ Service::WIN32_SHARE_PROCESS
278
+ Service that shares a process with one or more other services.
279
+
280
+ Service::INTERACTIVE_PROCESS
281
+ The service can interact with the desktop. This can only be used if
282
+ either SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS is
283
+ specified as well, and the service is running in the context of the
284
+ LocalSystem account (which is the default for this module, btw).
285
+
286
+ === Start Type Constants
287
+ Service::AUTO_START
288
+ A service started automatically by the service control manager during
289
+ system startup.
290
+
291
+ Service::BOOT_START
292
+ A device driver started by the system loader. This value is valid only
293
+ for driver services.
294
+
295
+ Service::DEMAND_START
296
+ A service started by the service control manager when a process calls
297
+ the StartService() function.
298
+
299
+ Service::DISABLED
300
+ A service that cannot be started. Attempts to start the service result
301
+ in an error.
302
+
303
+ Service::SYSTEM_START
304
+ A device driver started by the IoInitSystem() function. This value is
305
+ valid only for driver services.
306
+
307
+ === Error Control Constants
308
+ Service::ERROR_IGNORE
309
+ The startup program logs the error but continues the startup operation.
310
+
311
+ Service::ERROR_NORMAL
312
+ The startup program logs the error and puts up a message box pop-up but
313
+ continues the startup operation.
314
+
315
+ Service::ERROR_SEVERE
316
+ The startup program logs the error. If the last-known-good configuration
317
+ is being started, the startup operation continues. Otherwise, the system
318
+ is restarted with the last-known-good configuration.
319
+
320
+ Service::ERROR_CRITICAL
321
+ The startup program logs the error, if possible. If the last-known-good
322
+ configuration is being started the startup operation fails. Otherwise,
323
+ the system is restarted with the last-known-good configuration.
324
+
325
+ = Notes
326
+ See the MSDN API with regards to CreateService(), etc at
327
+ http://www.msdn.com
328
+
329
+ Some API ideas taken (or not) from both Python's win32serviceutil.py and
330
+ Perl's Win32::Service module.
331
+
332
+ I don't truly understand how to allow a tag_id in the create_service()
333
+ method, so for now it's set to NULL automatically. Suggestions welcome.
334
+
335
+ = Known Bugs
336
+ There may be a failure in the test suite if the W32Time dependency is
337
+ not started.
338
+
339
+ If you find any bugs please log them on the bug tracker. You can find it
340
+ on the project page at http://www.rubyforge.org/projects/win32utils.
341
+
342
+ = Acknowledgements
343
+ Many thanks go to Patrick Hurley for providing the fix for the thread
344
+ blocking issue. Thanks also go to Kevin Burge for his patch that solved
345
+ service responsiveness issues.
346
+
347
+ = Future Plans
348
+ Add Tag_ID support.
349
+ Add ability to create or modify service failure actions.
350
+ Use RegisterServiceCtrlHandlerEx().
351
+
352
+ = Copyright
353
+ (C) 2003-2008, Daniel J. Berger, All Rights Reserved
354
+
355
+ = License
356
+ Ruby's
357
+
358
+ = Warranty
359
+ This package is provided "as is" and without any express or
360
+ implied warranties, including, without limitation, the implied
361
+ warranties of merchantability and fitness for a particular purpose.
362
+
363
+ == Author(s)
364
+ * Daniel J. Berger
365
+ * Park Heesob