TestimoX

API Reference

Class

WindowsServiceManager

Namespace ComputerX.Services
Assembly ComputerX
Modifiers static
Attributes
SupportedOSPlatform("windows")

Local Windows service lifecycle helpers for install, uninstall, status, and start/stop operations.

Inheritance

  • Object
  • WindowsServiceManager

Methods

BackupCommandLine 2 overloads
public static Void BackupCommandLine(String serviceName, String backupPath) #
Returns: Void

Backs up the current SCM binary path for a local Windows service to a file on the current machine.

Parameters

serviceName System.String requiredposition: 0
backupPath System.String requiredposition: 1
public static Void BackupCommandLine(String machineName, String serviceName, String backupPath) #
Returns: Void

Backs up the current SCM binary path for a Windows service to a file on the current machine.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
backupPath System.String requiredposition: 2
EnsureInstalled 2 overloads
public static WindowsServiceStatusSnapshot EnsureInstalled(WindowsServiceInstallRequest request) #
Returns: WindowsServiceStatusSnapshot

Creates a Windows service when missing or updates it when already installed.

Parameters

request ComputerX.Services.WindowsServiceInstallRequest requiredposition: 0
public static WindowsServiceStatusSnapshot EnsureInstalled(String machineName, WindowsServiceInstallRequest request) #
Returns: WindowsServiceStatusSnapshot

Creates a Windows service on the specified computer when missing or updates it when already installed.

Parameters

machineName System.String requiredposition: 0
request ComputerX.Services.WindowsServiceInstallRequest requiredposition: 1
GetCommandLine 2 overloads
public static WindowsServiceCommandLine GetCommandLine(String serviceName) #
Returns: WindowsServiceCommandLine

Returns the parsed SCM binary path for a local Windows service.

Parameters

serviceName System.String requiredposition: 0
public static WindowsServiceCommandLine GetCommandLine(String machineName, String serviceName) #
Returns: WindowsServiceCommandLine

Returns the parsed SCM binary path for a Windows service on the specified computer.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
GetConfiguration 2 overloads
public static WindowsServiceConfigurationSnapshot GetConfiguration(String serviceName) #
Returns: WindowsServiceConfigurationSnapshot

Returns the current Service Control Manager configuration for a local Windows service.

Parameters

serviceName System.String requiredposition: 0
public static WindowsServiceConfigurationSnapshot GetConfiguration(String machineName, String serviceName) #
Returns: WindowsServiceConfigurationSnapshot

Returns the current Service Control Manager configuration for a Windows service on the specified computer.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
GetStatus 2 overloads
public static WindowsServiceStatusSnapshot GetStatus(String serviceName) #
Returns: WindowsServiceStatusSnapshot

Returns the current status snapshot for a local Windows service.

Parameters

serviceName System.String requiredposition: 0
public static WindowsServiceStatusSnapshot GetStatus(String machineName, String serviceName) #
Returns: WindowsServiceStatusSnapshot

Returns the current status snapshot for a Windows service on the specified computer.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
Install 2 overloads
public static WindowsServiceStatusSnapshot Install(WindowsServiceInstallRequest request) #
Returns: WindowsServiceStatusSnapshot

Creates a Windows service and optionally starts it.

Parameters

request ComputerX.Services.WindowsServiceInstallRequest requiredposition: 0
public static WindowsServiceStatusSnapshot Install(String machineName, WindowsServiceInstallRequest request) #
Returns: WindowsServiceStatusSnapshot

Creates a Windows service on the specified computer and optionally starts it.

Parameters

machineName System.String requiredposition: 0
request ComputerX.Services.WindowsServiceInstallRequest requiredposition: 1
Restart 2 overloads
public static WindowsServiceStatusSnapshot Restart(String serviceName, Nullable<TimeSpan> timeout = null) #
Returns: WindowsServiceStatusSnapshot

Restarts an installed Windows service.

Parameters

serviceName System.String requiredposition: 0
timeout System.Nullable{System.TimeSpan} = null optionalposition: 1
public static WindowsServiceStatusSnapshot Restart(String machineName, String serviceName, Nullable<TimeSpan> timeout = null) #
Returns: WindowsServiceStatusSnapshot

Restarts an installed Windows service on the specified computer.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
timeout System.Nullable{System.TimeSpan} = null optionalposition: 2
RestoreCommandLine 2 overloads
public static Boolean RestoreCommandLine(String serviceName, String backupPath, String executablePathOverride = null, Boolean deleteBackupFile = true) #
Returns: Boolean

Restores the SCM binary path for a local Windows service from a backup file on the current machine.

Parameters

serviceName System.String requiredposition: 0
backupPath System.String requiredposition: 1
executablePathOverride System.String = null optionalposition: 2
deleteBackupFile System.Boolean = true optionalposition: 3
public static Boolean RestoreCommandLine(String machineName, String serviceName, String backupPath, String executablePathOverride, Boolean deleteBackupFile) #
Returns: Boolean

Restores the SCM binary path for a Windows service from a backup file on the current machine.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
backupPath System.String requiredposition: 2
executablePathOverride System.String requiredposition: 3
deleteBackupFile System.Boolean requiredposition: 4
Start 2 overloads
public static WindowsServiceStatusSnapshot Start(String serviceName, Nullable<TimeSpan> timeout = null) #
Returns: WindowsServiceStatusSnapshot

Starts an installed Windows service.

Parameters

serviceName System.String requiredposition: 0
timeout System.Nullable{System.TimeSpan} = null optionalposition: 1
public static WindowsServiceStatusSnapshot Start(String machineName, String serviceName, Nullable<TimeSpan> timeout = null) #
Returns: WindowsServiceStatusSnapshot

Starts an installed Windows service on the specified computer.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
timeout System.Nullable{System.TimeSpan} = null optionalposition: 2
Stop 2 overloads
public static WindowsServiceStatusSnapshot Stop(String serviceName, Nullable<TimeSpan> timeout = null) #
Returns: WindowsServiceStatusSnapshot

Stops an installed Windows service.

Parameters

serviceName System.String requiredposition: 0
timeout System.Nullable{System.TimeSpan} = null optionalposition: 1
public static WindowsServiceStatusSnapshot Stop(String machineName, String serviceName, Nullable<TimeSpan> timeout = null) #
Returns: WindowsServiceStatusSnapshot

Stops an installed Windows service on the specified computer.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
timeout System.Nullable{System.TimeSpan} = null optionalposition: 2
public static Boolean TryPrepareCommandLine(String persistedValue, String executablePath, IEnumerable<String> requiredOptions, IEnumerable<KeyValuePair<String, String>> optionOverrides, out WindowsServiceCommandLine commandLine) #
Returns: Boolean

Tries to prepare a rebased command line from a persisted service binary path and optional option overrides.

Parameters

persistedValue System.String requiredposition: 0
executablePath System.String requiredposition: 1
requiredOptions System.Collections.Generic.IEnumerable{System.String} requiredposition: 2
optionOverrides System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} requiredposition: 3
commandLine ComputerX.Services.WindowsServiceCommandLine@ requiredposition: 4
TryReadCommandLineBackup 3 overloads
public static Boolean TryReadCommandLineBackup(String backupPath, out WindowsServiceCommandLine commandLine) #
Returns: Boolean

Tries to read a previously backed up service command line from a file on the current machine.

Parameters

backupPath System.String requiredposition: 0
commandLine ComputerX.Services.WindowsServiceCommandLine@ requiredposition: 1
public static Boolean TryReadCommandLineBackup(String backupPath, String executablePathOverride, out WindowsServiceCommandLine commandLine) #
Returns: Boolean

Tries to read a previously backed up service command line from a file on the current machine and optionally rebases it to another executable path.

Parameters

backupPath System.String requiredposition: 0
executablePathOverride System.String requiredposition: 1
commandLine ComputerX.Services.WindowsServiceCommandLine@ requiredposition: 2
public static Boolean TryReadCommandLineBackup(String backupPath, String executablePathOverride, IEnumerable<String> requiredOptions, IEnumerable<KeyValuePair<String, String>> optionOverrides, out WindowsServiceCommandLine commandLine) #
Returns: Boolean

Tries to read and prepare a command line from a backup file using required option checks and option overrides.

Parameters

backupPath System.String requiredposition: 0
executablePathOverride System.String requiredposition: 1
requiredOptions System.Collections.Generic.IEnumerable{System.String} requiredposition: 2
optionOverrides System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} requiredposition: 3
commandLine ComputerX.Services.WindowsServiceCommandLine@ requiredposition: 4
Uninstall 2 overloads
public static WindowsServiceStatusSnapshot Uninstall(String serviceName, Nullable<TimeSpan> timeout = null) #
Returns: WindowsServiceStatusSnapshot

Deletes an installed Windows service.

Parameters

serviceName System.String requiredposition: 0
timeout System.Nullable{System.TimeSpan} = null optionalposition: 1
public static WindowsServiceStatusSnapshot Uninstall(String machineName, String serviceName, Nullable<TimeSpan> timeout = null) #
Returns: WindowsServiceStatusSnapshot

Deletes an installed Windows service from the specified computer.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
timeout System.Nullable{System.TimeSpan} = null optionalposition: 2
Update 2 overloads
public static WindowsServiceStatusSnapshot Update(WindowsServiceInstallRequest request) #
Returns: WindowsServiceStatusSnapshot

Updates an installed Windows service and optionally starts it.

Parameters

request ComputerX.Services.WindowsServiceInstallRequest requiredposition: 0
public static WindowsServiceStatusSnapshot Update(String machineName, WindowsServiceInstallRequest request) #
Returns: WindowsServiceStatusSnapshot

Updates an installed Windows service on the specified computer and optionally starts it.

Parameters

machineName System.String requiredposition: 0
request ComputerX.Services.WindowsServiceInstallRequest requiredposition: 1
UpdateCommandLine 2 overloads
public static Void UpdateCommandLine(String serviceName, WindowsServiceCommandLine commandLine, String displayName = null) #
Returns: Void

Updates only the SCM binary path for an installed local Windows service.

Parameters

serviceName System.String requiredposition: 0
commandLine ComputerX.Services.WindowsServiceCommandLine requiredposition: 1
displayName System.String = null optionalposition: 2
public static Void UpdateCommandLine(String machineName, String serviceName, WindowsServiceCommandLine commandLine, String displayName = null) #
Returns: Void

Updates only the SCM binary path for an installed Windows service on the specified computer.

Parameters

machineName System.String requiredposition: 0
serviceName System.String requiredposition: 1
commandLine ComputerX.Services.WindowsServiceCommandLine requiredposition: 2
displayName System.String = null optionalposition: 3