PeanutButter
|
The legacy, native WindowsServiceUtil which uses the win32api to provide service management. More...
Public Member Functions | |||||
NativeWindowsServiceUtil (string serviceName) | |||||
NativeWindowsServiceUtil (string serviceName, string displayName, string serviceCommandline) | |||||
Construct a windows service util with service name, description and commandline - typically the constructor used when registering a service for the first time. | |||||
void | Uninstall () | ||||
Uninstalls the service. If the service is not found by name, does nothing. | |||||
void | Uninstall (bool waitForUninstall) | ||||
Uninstalls the service. If the service is not found by name, does nothing. Will wait for the uninstallation to complete. | |||||
void | Uninstall (ControlOptions options) | ||||
More control over uninstallation.
| |||||
void | InstallAndStart () | ||||
Installs the service as AutoStart and starts it, waiting for the service to report that it's running. | |||||
void | InstallAndStart (bool waitForStart) | ||||
Install and start the service as AutoStarting, with control over whether to wait for the service to have properly started.
| |||||
void | InstallAndStart (ServiceStartupTypes startupType, bool waitForStart) | ||||
Install and start the service, with control over whether to wait for the service to have properly started.
| |||||
void | Install () | ||||
Installs the service with automatic start. Will error if the service is already found by name. | |||||
void | Install (ServiceStartupTypes startupType) | ||||
Install with the provided startup type.
| |||||
void | Disable () | ||||
Disable the service from running. | |||||
void | SetAutomaticStart () | ||||
Set the service to automatically start with the host system. | |||||
void | SetManualStart () | ||||
Set the service to require manual start. | |||||
void | Start () | ||||
Start the service and wait for it to be running. | |||||
void | Start (bool wait) | ||||
Start the service Explicitly wait or not for it to start.
| |||||
void | Stop () | ||||
Stop the service and wait for it to be running. | |||||
void | Stop (bool wait) | ||||
Start the service Explicitly wait or not for it to stop.
| |||||
void | Stop (ControlOptions options) | ||||
Stop the service with the provided control options.
| |||||
void | Pause () | ||||
Pause the service, waiting for it to enter the paused state. | |||||
void | Pause (bool wait) | ||||
Pause the service Explicitly wait or not for it to pause. | |||||
void | Continue () | ||||
Continue the service, waiting for it to enter the continued state. | |||||
void | Continue (bool wait) | ||||
Continue the service Explicitly wait or not for it to continue. | |||||
KillServiceResult | KillService () | ||||
Kills the service, if running.
| |||||
void | ConfigureStartup (ServiceStartupTypes startupType) | ||||
Configure the service's startup type.
|
Static Public Member Functions | |
static IWindowsServiceUtil | GetServiceByPid (int pid) |
Attempt to load a WindowsServiceUtil by the pid of a running process. | |
static WindowsServiceUtil | GetServiceByPath (string path) |
Attempt to load a WindowsServiceUtil by a full path to the executable. |
Properties | |
bool | IsDisabled [get] |
Whether or not the service is disabled -> this is a shortcut to check the startup type vs the disabled startup type. | |
bool | IsPaused [get] |
Whether or not the service is paused.
| |
bool | IsRunning [get] |
Whether or not the service is running.
| |
string | ServiceName [get] |
The name of the service, usable from, eg 'net stop {name}'. | |
bool | IsStoppable [get] |
True if the service is in a stoppable state. | |
bool | IsStartable [get] |
True if the service is in a startable state. | |
string | DisplayName [get, set] |
The name displayed in the service manager (service.msc) | |
string | Commandline [get] |
The full commandline for this service. | |
string | ServiceExe [get] |
The path to the service executable. | |
string[] | Arguments [get] |
The arguments that the service is started with. | |
int | ServiceStateExtraWaitSeconds [get, set] |
In addition to the amount of time that the service control manager would normally wait for a service to respond to a control request (typically 30s, but this can be overridden on the host machine), the util will wait this number of seconds extra for your service to change state on blocking control requests. | |
ServiceState | State [get] |
The current state of this service. | |
bool | IsInstalled [get] |
Whether or not the service is installed -> this is a shortcut to check startup type vs unknown. | |
bool | IsMarkedForDelete [get] |
Test if the service is marked for deletion. | |
int | ServicePID [get] |
The process id for a running process (0 when not running) | |
ServiceStartupTypes | StartupType [get] |
The startup type of the service. |
The legacy, native WindowsServiceUtil which uses the win32api to provide service management.
PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.NativeWindowsServiceUtil | ( | string | serviceName, |
string | displayName, | ||
string | serviceCommandline ) |
Construct a windows service util with service name, description and commandline - typically the constructor used when registering a service for the first time.
serviceName | |
displayName | |
serviceCommandline |
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.ConfigureStartup | ( | ServiceStartupTypes | startupType | ) |
Configure the service's startup type.
startupType |
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Continue | ( | ) |
Continue the service, waiting for it to enter the continued state.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Continue | ( | bool | wait | ) |
Continue the service Explicitly wait or not for it to continue.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Disable | ( | ) |
Disable the service from running.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
static |
Attempt to load a WindowsServiceUtil by a full path to the executable.
path |
ArgumentException |
|
static |
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Install | ( | ) |
Installs the service with automatic start. Will error if the service is already found by name.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Install | ( | ServiceStartupTypes | startupType | ) |
Install with the provided startup type.
startupType |
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.InstallAndStart | ( | ) |
Installs the service as AutoStart and starts it, waiting for the service to report that it's running.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.InstallAndStart | ( | bool | waitForStart | ) |
Install and start the service as AutoStarting, with control over whether to wait for the service to have properly started.
wait |
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.InstallAndStart | ( | ServiceStartupTypes | startupType, |
bool | waitForStart ) |
Install and start the service, with control over whether to wait for the service to have properly started.
startupType | |
wait |
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
KillServiceResult PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.KillService | ( | ) |
Kills the service, if running.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Pause | ( | ) |
Pause the service, waiting for it to enter the paused state.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Pause | ( | bool | wait | ) |
Pause the service Explicitly wait or not for it to pause.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.SetAutomaticStart | ( | ) |
Set the service to automatically start with the host system.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.SetManualStart | ( | ) |
Set the service to require manual start.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Start | ( | ) |
Start the service and wait for it to be running.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Start | ( | bool | wait | ) |
Start the service Explicitly wait or not for it to start.
wait |
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Stop | ( | ) |
Stop the service and wait for it to be running.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Stop | ( | bool | wait | ) |
Start the service Explicitly wait or not for it to stop.
wait |
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Stop | ( | ControlOptions | options | ) |
Stop the service with the provided control options.
options |
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Uninstall | ( | ) |
Uninstalls the service. If the service is not found by name, does nothing.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Uninstall | ( | bool | waitForUninstall | ) |
Uninstalls the service. If the service is not found by name, does nothing. Will wait for the uninstallation to complete.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
void PeanutButter.WindowsServiceManagement.NativeWindowsServiceUtil.Uninstall | ( | ControlOptions | options | ) |
More control over uninstallation.
options |
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
The arguments that the service is started with.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
The full commandline for this service.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
getset |
The name displayed in the service manager (service.msc)
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
Whether or not the service is disabled -> this is a shortcut to check the startup type vs the disabled startup type.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
Whether or not the service is installed -> this is a shortcut to check startup type vs unknown.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
Test if the service is marked for deletion.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
Whether or not the service is paused.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
Whether or not the service is running.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
True if the service is in a startable state.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
True if the service is in a stoppable state.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
The path to the service executable.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
The name of the service, usable from, eg 'net stop {name}'.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
The process id for a running process (0 when not running)
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
The startup type of the service.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.
|
get |
The current state of this service.
Implements PeanutButter.WindowsServiceManagement.IWindowsServiceUtil.