Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Static class: RT.Services.SingleSelfService

Summary

Provides utility methods for creating executables which can install and uninstall themselves as a service, and run both as a service and as a standard process. This class does not support processes which host multiple services.

Static methods

void
ExecuteAsService(Action onStart, Action onStop = null, Action onShutdown = null, Func<PowerBroadcastStatus, bool> onPowerEvent = null)
Passes control to the service manager, and configures callbacks to be used by the service manager in response to various events. This method must be called when the process is invoked with command line arguments specified in SingleSelfService.Install(string, string, string, string, ServiceStartMode, ServiceAccount, string, string, IList<string>). Does not return (unless called outside of SCM control, in which case it shows a generic error message and terminates the process).
void
Install(string name, string displayName, string description, string exeArgs, ServiceStartMode start = Automatic, ServiceAccount account = ServiceAccount.LocalService, string username = null, string password = null, IList<string> servicesDependedOn = null)
Registers the running executable as an own-process Windows Service using the specified options. Throws a ServiceAlreadyExistsException if a service with the same name or display name already exists. Throws a Win32Exception for other errors.
void
Uninstall(string name)
Un-registers a service with the specified name. Note that this method can uninstall any service, not only those registered with SingleSelfService.Install(string, string, string, string, ServiceStartMode, ServiceAccount, string, string, IList<string>). Throws a ServiceNotFoundException if no such service exists, or a Win32Exception for other errors.