API Reference
WindowsServiceCommandLine
Represents a Windows service executable path plus its command-line arguments.
Inheritance
- Object
- WindowsServiceCommandLine
Constructors
public WindowsServiceCommandLine(String executablePath, IEnumerable<String> arguments = null) #Initializes a new instance of the WindowsServiceCommandLine class.
Parameters
- executablePath System.String
- Executable path used by the service.
- arguments System.Collections.Generic.IEnumerable{System.String} = null
- Arguments passed to the service process.
Methods
public String GetOptionValue(String option) #StringReturns the value for the specified option when present.
Parameters
- option System.String
- Option name, for example --config.
Returns
Option value or null when the option is not present.
public String GetResolvedOptionPath(String option) #StringResolves an option value as a filesystem path relative to the executable directory when needed.
Parameters
- option System.String
- Option name, for example --config.
Returns
Resolved option path or null when the option is not present.
public Boolean HasOption(String option) #BooleanReturns whether the command line contains the specified option.
Parameters
- option System.String
- Option name, for example --config.
Returns
true when the option is present; otherwise false.
public static WindowsServiceCommandLine Parse(String commandLine) #WindowsServiceCommandLineParses an SCM binary path into a strongly typed command line.
Parameters
- commandLine System.String
- Raw SCM binary path.
Returns
Parsed command line.
public static WindowsServiceCommandLine ParsePersistedValue(String persistedValue) #WindowsServiceCommandLineParses a persisted service command-line value into a strongly typed command line.
Parameters
- persistedValue System.String
- Persisted SCM binary path or a registry-export style value containing ImagePath.
Returns
Parsed command line.
public String ResolvePath(String path) #StringResolves a path relative to the executable directory after expanding environment variables.
Parameters
- path System.String
- Path to resolve.
Returns
Resolved path.
public String ToImagePath() #StringConverts the command line back into the SCM binary path format. Options are normalized to quoted split arguments as needed for SCM-safe round-tripping.
Returns
Serialized SCM binary path.
public override String ToString() #StringConverts the command line back into the SCM binary path format.
Returns
Serialized SCM binary path.
public static Boolean TryParse(String commandLine, out WindowsServiceCommandLine parsed) #BooleanParses an SCM binary path into a strongly typed command line.
Parameters
- commandLine System.String
- Raw SCM binary path.
- parsed ComputerX.Services.WindowsServiceCommandLine@
- Parsed command line.
Returns
true when parsing succeeds; otherwise false.
public static Boolean TryParsePersistedValue(String persistedValue, out WindowsServiceCommandLine parsed) #BooleanParses a persisted service command-line value into a strongly typed command line.
Parameters
- persistedValue System.String
- Persisted SCM binary path or a registry-export style value containing ImagePath.
- parsed ComputerX.Services.WindowsServiceCommandLine@
- Parsed command line.
Returns
true when parsing succeeds; otherwise false.
public WindowsServiceCommandLine WithExecutablePath(String executablePath) #WindowsServiceCommandLineCreates a copy of the command line with a different executable path.
Parameters
- executablePath System.String
- New executable path.
Returns
Updated command line.
public WindowsServiceCommandLine WithOptionValue(String option, String value) #WindowsServiceCommandLineCreates a copy of the command line with the specified option value replaced or appended.
Parameters
- option System.String
- Option name, for example --config.
- value System.String
- Option value.
Returns
Updated command line.
public WindowsServiceCommandLine WithOptionValues(IEnumerable<KeyValuePair<String, String>> optionValues) #WindowsServiceCommandLineCreates a copy of the command line with multiple option values replaced or appended.
Parameters
- optionValues System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}}
- Option values keyed by canonical option name.
Returns
Updated command line.
Inherited Methods
Properties
public String ExecutablePath { get; } #Gets the executable path used by the service.
public String ExpandedExecutablePath { get; } #Gets the executable path after expanding environment variables.
public String ExecutableDirectory { get; } #Gets the directory that contains the service executable, when it can be determined.
public IReadOnlyList<String> Arguments { get; } #Gets the command-line arguments passed after the executable path.