ScManager
An open handle to the Windows Service Control Manager.
Returned by open.
Methods
close()
Closes the manager.
Closing an already-closed manager does nothing.
create_service name … -> Service
Creates a service.
Parameters
| Name | Type | Description |
|---|---|---|
name |
Str |
Service name. |
:display_name? |
Str |
Display name. Omit to pass NULL to Windows. |
:binary_path? |
(Str | fs.Path) |
Service executable path or command line. Omit to pass NULL to Windows. |
:service_type? |
ServiceTypeSpec |
Service type. Defaults to :WIN32_OWN_PROCESS:. |
:start_type? |
StartType |
Start type. Defaults to :DEMAND_START:. |
:error_control? |
ErrorControl |
Error control level. Defaults to :NORMAL:. |
:access? |
ServiceAccessMaskSpec |
Rights the returned handle requests. Defaults to
:SERVICE_QUERY_STATUS:. |
:load_order_group? |
Str |
Load-order group. |
:dependencies? |
Iterable[Str] |
Service or load-order-group names this service depends on. |
:service_start_name? |
Str |
Account the service runs as. |
:password? |
Str |
Password for service_start_name. |
:binary_path
A Str is passed to Windows verbatim. An absolute
fs.windows.Path is used as the executable path
and quoted when needed. An iterable supplies command arguments as
Str values or absolute
fs.windows.Path values; each element is quoted
with the Windows command-line rules.
Example
let service = manager.create_service my-service
display_name: My Service
binary_path: [r"C:\Program Files\My Service\service.exe"]
access: :SERVICE_ALL_ACCESS:
create_service[R] name func … -> R
Creates a service and calls func with it. The service handle is closed
when func returns.
Parameters
| Name | Type | Description |
|---|---|---|
name |
Str |
Service name. |
:display_name? |
Str |
Display name. Omit to pass NULL to Windows. |
:binary_path? |
(Str | fs.Path) |
Service executable path or command line. Omit to pass NULL to Windows. |
:service_type? |
ServiceTypeSpec |
Service type. Defaults to :WIN32_OWN_PROCESS:. |
:start_type? |
StartType |
Start type. Defaults to :DEMAND_START:. |
:error_control? |
ErrorControl |
Error control level. Defaults to :NORMAL:. |
:access? |
ServiceAccessMaskSpec |
Rights the returned handle requests. Defaults to
:SERVICE_QUERY_STATUS:. |
:load_order_group? |
Str |
Load-order group. |
:dependencies? |
Iterable[Str] |
Service or load-order-group names this service depends on. |
:service_start_name? |
Str |
Account the service runs as. |
:password? |
Str |
Password for service_start_name. |
func |
((Service) -> R) |
Called with the Service. |
enumerate_services … -> Iter[ServiceInfo]
Opens a live forward enumeration of matching services. Entries are fetched from Windows as iteration advances.
Parameters
| Name | Type | Description |
|---|---|---|
:service_type? |
ServiceTypeSpec |
Types to include. Defaults to :WIN32:. |
:state_filter? |
StateFilter |
Which services to include. Defaults to :ALL:. |
Example
open_service name … -> Service
Opens an existing service.
Parameters
| Name | Type | Description |
|---|---|---|
name |
Str |
Service name. |
:access? |
ServiceAccessMaskSpec |
Rights the returned handle requests. Defaults to
:SERVICE_QUERY_STATUS:. |
Errors
| Exception | Condition |
|---|---|
sys.NotFoundError |
The service does not exist |
Example
manager.open_service Spooler access: :SERVICE_QUERY_STATUS: do |service|
echo $service.query_status().current_state
open_service[R] name func … -> R
Opens an existing service and calls func with it. The service handle is
closed when func returns.
Parameters
| Name | Type | Description |
|---|---|---|
name |
Str |
Service name. |
:access? |
ServiceAccessMaskSpec |
Rights the returned handle requests. Defaults to
:SERVICE_QUERY_STATUS:. |
func |
((Service) -> R) |
Called with the Service. |