Ejemplo n.º 1
0
        public void StopRadeonSoftware()
        {
            try
            {
                StaticViewModel.AddLogMessage("Stopping Radeon Software Host Services");
                StaticViewModel.IsLoading = true;

                RadeonSoftwareCli(CNCMD_EXIT);

                //The command to stop the services does not wait for them to fully end
                ProcessHandler hostProcess = new ProcessHandler(_cnDir.FullName + "AMDRSServ.exe");
                hostProcess.WaitForProcessToEnd(30);
                ProcessHandler radeonSoftwareProcess = new ProcessHandler(_cnDir.FullName + "RadeonSoftware.exe");
                radeonSoftwareProcess.WaitForProcessToEnd(30);

                StaticViewModel.AddLogMessage("Stopped Radeon Software Host Services");
            }
            catch (Exception ex)
            {
                StaticViewModel.AddLogMessage(ex, "Failed to stop Radeon Software Host Services");
            }
            finally
            {
                LoadOrRefresh();
                StaticViewModel.IsLoading = false;
            }
        }
Ejemplo n.º 2
0
        public void RestartRadeonSoftware()
        {
            try
            {
                StaticViewModel.AddLogMessage("Restarting Radeon Software Host Services");
                StaticViewModel.IsLoading = true;

                RadeonSoftwareCli(CNCMD_RESTART);

                //Wait for services to start back up
                ProcessHandler radeonSoftwareProcess = new ProcessHandler(_cnDir.FullName + "RadeonSoftware.exe");
                radeonSoftwareProcess.WaitForProcessToStart(30);


                StaticViewModel.AddLogMessage("Restarted Radeon Software Host Services");
            }
            catch (Exception ex)
            {
                StaticViewModel.AddLogMessage(ex, "Failed to restart Radeon Software Host Services");
            }
            finally
            {
                LoadOrRefresh();
                StaticViewModel.IsLoading = false;
            }
        }
Ejemplo n.º 3
0
        private void SetStartMode(ServiceStartMode startMode)
        {
            using (ServiceController serviceController = LoadFreshService())
            {
                //It's this or WMI...
                ProcessHandler processHandler = new ProcessHandler(Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\sc.exe");
                processHandler.RunProcess($"config \"{Name}\" start= {GetStartModeCommandString(startMode)}");

                serviceController.Refresh();
                StartMode = serviceController.StartType;
                Enabled   = serviceController.StartType != ServiceStartMode.Disabled;

                StaticViewModel.AddLogMessage($"Changed start mode for {Name} to {StartMode}");
            }
        }
Ejemplo n.º 4
0
        public bool ValidateInstallerFile()
        {
            if (string.IsNullOrWhiteSpace(_installerFile))
            {
                StaticViewModel.AddLogMessage($"Please provide an installer file");
                return(false);
            }

            if (!File.Exists(_installerFile))
            {
                StaticViewModel.AddLogMessage($"Installer file {_installerFile} does not exist or cannot be accessed");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        public void TryStop()
        {
            if (_serviceType.HasFlag(ServiceType.KernelDriver))
            {
                StaticViewModel.AddLogMessage($"Cannot stop {Name} because it is a kernel driver");
                return;
            }

            try
            {
                StaticViewModel.AddLogMessage("Stopping " + Name);
                StaticViewModel.IsLoading = true;

                using (ServiceController serviceController = LoadFreshService())
                {
                    if (serviceController.Status == ServiceControllerStatus.Running && serviceController.ServiceType.HasFlag(ServiceType.Win32OwnProcess))
                    {
                        try
                        {
                            serviceController.Stop();
                            serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(30));
                        }
                        catch (InvalidOperationException ex)
                        {
                            StaticViewModel.AddDebugMessage(ex);
                        }

                        Status = serviceController.Status;
                    }
                }

                StaticViewModel.AddLogMessage("Stopped " + Name);
            }
            catch (Exception ex)
            {
                StaticViewModel.AddLogMessage(ex, "Failed to stop " + Name);
            }
            finally
            {
                StaticViewModel.IsLoading = false;
            }
        }
Ejemplo n.º 6
0
        public void TryStart()
        {
            if (_startMode == ServiceStartMode.Disabled)
            {
                StaticViewModel.AddLogMessage($"Cannot start {Name} because it is disabled");
                return;
            }

            if (_serviceType.HasFlag(ServiceType.KernelDriver))
            {
                StaticViewModel.AddLogMessage($"Cannot start {Name} because it is a kernel driver");
                return;
            }

            try
            {
                StaticViewModel.AddLogMessage("Restarting " + Name);
                StaticViewModel.IsLoading = true;

                TryStop();

                using (ServiceController serviceController = LoadFreshService())
                {
                    if (serviceController.StartType != ServiceStartMode.Disabled && serviceController.ServiceType.HasFlag(ServiceType.Win32OwnProcess))
                    {
                        serviceController.Start();
                        serviceController.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(30));

                        Status = serviceController.Status;
                        StaticViewModel.AddLogMessage("Restarted " + Name);
                    }
                }
            }
            catch (Exception ex)
            {
                StaticViewModel.AddLogMessage(ex, "Failed to restart " + Name);
            }
            finally
            {
                StaticViewModel.IsLoading = false;
            }
        }
Ejemplo n.º 7
0
        public bool ValidateExtractLocation(bool alreadyExtracted)
        {
            if (string.IsNullOrWhiteSpace(_extractedInstallerDirectory))
            {
                StaticViewModel.AddLogMessage($"Please enter an extraction path");
                return(false);
            }

            DirectoryInfo directoryInfo = new DirectoryInfo(_extractedInstallerDirectory);

            if (alreadyExtracted)
            {
                if (directoryInfo.Exists)
                {
                    if (directoryInfo.GetFiles("Setup.exe", SearchOption.TopDirectoryOnly).Length != 1 ||
                        directoryInfo.GetDirectories("Bin64", SearchOption.TopDirectoryOnly).Length != 1 ||
                        directoryInfo.GetDirectories("Config", SearchOption.TopDirectoryOnly).Length != 1)
                    {
                        StaticViewModel.AddLogMessage($"Installer files not found in {_extractedInstallerDirectory}");
                        return(false);
                    }

                    return(true);
                }
                else
                {
                    StaticViewModel.AddLogMessage($"Installer files not found in {_extractedInstallerDirectory}");
                    return(false);
                }
            }
            else
            {
                if (directoryInfo.Exists && (directoryInfo.GetDirectories().Length > 1 || directoryInfo.GetFiles().Length > 1))
                {
                    StaticViewModel.AddLogMessage($"Extraction folder {_extractedInstallerDirectory} is not empty");
                    return(false);
                }

                return(true);
            }
        }
Ejemplo n.º 8
0
 private static void LogUnhandledException(Exception exception)
 {
     StaticViewModel.AddLogMessage(exception);
     StaticViewModel.IsLoading = false;
 }
Ejemplo n.º 9
0
 public void ClearFolder()
 {
     StaticViewModel.AddLogMessage($"Clearing folder {Folder}");
     ClearFolder(Folder);
 }