Esempio n. 1
0
        public void RegisterService()
        {
            var serviceDetails = GetWindowsServiceDetails();
            var dependencies   = GetServiceDependencies();

            WindowsServiceController.RegisterNewService(serviceDetails, dependencies.ToArray());

            // Service registered so pull out not configured flag files.
            RemoveFlagFiles();
        }
        public void CreateAService()
        {
            var s = new WindowsServiceDetails
            {
                ImagePath         = @"C:\Program Files (x86)\Particular Software\ServiceControl\ServiceControl.exe  --serviceName=Test.SC",
                DisplayName       = "Test SC",
                Name              = "Test.SC",
                ServiceAccount    = @"NT Authority\NetworkService",
                ServiceAccountPwd = null
            };

            var existing = InstanceFinder.ServiceControlInstances().FirstOrDefault(p => p.Name == s.Name);

            if (existing != null)
            {
                InstanceFinder.ServiceControlInstances().First(p => p.Name == s.Name).Service.Delete();
            }
            WindowsServiceController.RegisterNewService(s);
            InstanceFinder.ServiceControlInstances().First(p => p.Name == s.Name).Service.Delete();
        }
Esempio n. 3
0
        public void RegisterService()
        {
            var serviceDetails = new WindowsServiceDetails
            {
                ServiceAccount    = ServiceAccount,
                ServiceAccountPwd = ServiceAccountPwd,
                DisplayName       = DisplayName,
                Name               = Name,
                ImagePath          = $"\"{Path.Combine(InstallPath, Constants.ServiceControlExe)}\" --serviceName={Name}",
                ServiceDescription = ServiceDescription
            };
            var dependencies = new List <string>();

            if (TransportPackage.Equals("MSMQ", StringComparison.OrdinalIgnoreCase))
            {
                dependencies.Add("MSMQ");
            }
            WindowsServiceController.RegisterNewService(serviceDetails, dependencies.ToArray());

            // Service registered so pull out not configured flag files.
            RemoveFlagFiles();
        }