EBCEYS.OSServiceHelper
1.0.0.4
dotnet add package EBCEYS.OSServiceHelper --version 1.0.0.4
NuGet\Install-Package EBCEYS.OSServiceHelper -Version 1.0.0.4
<PackageReference Include="EBCEYS.OSServiceHelper" Version="1.0.0.4" />
<PackageVersion Include="EBCEYS.OSServiceHelper" Version="1.0.0.4" />
<PackageReference Include="EBCEYS.OSServiceHelper" />
paket add EBCEYS.OSServiceHelper --version 1.0.0.4
#r "nuget: EBCEYS.OSServiceHelper, 1.0.0.4"
#:package EBCEYS.OSServiceHelper@1.0.0.4
#addin nuget:?package=EBCEYS.OSServiceHelper&version=1.0.0.4
#tool nuget:?package=EBCEYS.OSServiceHelper&version=1.0.0.4
EBCEYS.OSServiceHelper
Описание:
Очень верхоуровневая абстракция поверх ServiceController для Windows.
Библиотека позволяет управлять службами в ОС Windows.
В методах установки, удаления и установки описания дергает sc.exe.
Библиотека на данный момент реализует интерфейс IOSServiceHelper и его имплементацию для ОС Windows WindowsServiceHelper.
IOSServiceHelper
Базовый интерфейс для ServiceHelper.
Содержит в себе несколько методов:
string ServiceName { get; }- имя службы.bool IsServiceExists();- проверка что служба установлена.bool IsServiceRunning();- проверка что служба запущена.bool IsServiceStoped();- проверка что служба остановлена.void StartService(string[]? args = null, WaitForStatusModel waitFor = default);- запуск службы.void StopService(bool stopDependetServices = false, WaitForStatusModel waitFor = default);- остановка службы.
IWindowsServiceHelper
Дополняет IOSServiceHelper.
Содержит в себе методы для работы со службами Windows:
bool DeleteService(TimeSpan waitForExit);- удаление службы !!!СТАРАЯ РЕАЛИЗАЦИЯ!!!.string? DeleteServiceWithOutput(TimeSpan waitForExit);- удаление службы.string? SetDescriptionForService(string description, WaitForStatusModel waitFor = default);- установка описания для службы.ServiceControllerStatus? GetServiceStatus();- получение статуса службы.bool RecreateService();- пересоздание инстансаServiceController.void InstallService(string path, InstallServiceStartMode startMode, WaitForStatusModel model = default);- установка службы.void PauseService(WaitForStatusModel waitFor = default);- постановка службы на паузу.
WindowsServiceHelper
Класс, наследуемый от интерфейса IWindowsServiceHelper, для работы со службами WINDOWS.
Логирование внутри осуществляется на уровне Debug && Trace.
Примеры
GitHub - EBCEYS.DayOfAllLoversService
Изменения:
v1.0.0.4:
- Исправлено логирование.
- В
IOSServiceHelperиWindowsServiceHelperсоответственно добавлен новый методstring? DeleteServiceWithOutput(TimeSpan waitForExit);(). - В
IOSServiceHelperиWindowsServiceHelperсоответственно методbool DeleteService(TimeSpan waitForExit);помечен как Obsolete.
v1.0.0.3:
- Изменен таргет фреймворк с .net8-windows на .net8.
- Исправлена ошибка, когда при значении параметра waitFor по умолчанию у метода
public void InstallService(string path, InstallServiceStartMode startMode = default, WaitForStatusModel waitFor = default)всегда выкидывалось исключение. - Параметр
loggerв конструктореWindowsServiceHelperсделан nullable.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.2)
- System.Management (>= 9.0.2)
- System.ServiceProcess.ServiceController (>= 9.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.