Esempio n. 1
0
        public virtual async Task InstallServiceAsync(IRemoteServiceInfo service)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (string.IsNullOrWhiteSpace(service.Name))
            {
                throw new ArgumentException("Value must not be empty",
                                            $"{nameof(service)}.{nameof(IRemoteServiceInfo.Name)}"
                                            );
            }
            if (string.IsNullOrWhiteSpace(service.Path))
            {
                throw new ArgumentException("Value must not be empty",
                                            $"{nameof(service)}.{nameof(IRemoteServiceInfo.Path)}"
                                            );
            }
            var services = await GetServicesAsync();

            if (services.Any(e => e == service.Name))
            {
                throw new InvalidOperationException(
                          $"Service is already installed"
                          );
            }
            await ExecuteAsync($@"SC CREATE ""{service.Name}"" start= auto binpath= ""{service.Path}""");
        }
Esempio n. 2
0
 public abstract Task InstallService(IRemoteServiceInfo service, CancellationToken token);