Beispiel #1
0
        public static void ProlexNet(string registryUninstallPath, string applicationGuid)
        {
            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(registryUninstallPath, true))
            {
                if (key != null)
                {
                    try
                    {
                        RegistryKey child = key.OpenSubKey(applicationGuid);
                        if (child != null)
                        {
                            var uninstall = MessageBox.Show("Tem certeza que deseja remover o ProlexNet? O banco de dados NÃO será removido.", "Aviso!", MessageBoxButton.YesNo, MessageBoxImage.Question);
                            if (uninstall == MessageBoxResult.Yes)
                            {
                                var rootPath = child.GetValue("RootLocation");
                                child.Close();
                                try
                                {
                                    ConfigIIS.RemoveSite("prolexnet");
                                    ConfigIIS.RemovePool("prolexnet");
                                    Firewall.RemoveRules();
                                    Directory.Delete(rootPath.ToString(), true);
                                    key.DeleteSubKey(applicationGuid, false);

                                    MessageBox.Show("ProlexNet removido com sucesso!", "Aviso!", MessageBoxButton.OK, MessageBoxImage.Information);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message, "Aviso!", MessageBoxButton.OK, MessageBoxImage.Error);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Erro!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            Application.Current.Shutdown();
        }
Beispiel #2
0
        public static async Task IIS(string installationPath, string port)
        {
            try
            {
                string dismVersion = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32", "dism.exe");
                if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
                {
                    dismVersion = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "sysnative", "dism.exe");
                }

                var servicePath    = CreateServicePath.ServicePath;
                var dismOutputFile = Path.Combine(servicePath, "dismOutput.txt");

                var tempComparer = new string[0];
                if (File.Exists(dismOutputFile))
                {
                    tempComparer = File.ReadAllLines(dismOutputFile);
                }

                var dismArgs = $"/Online /Get-Features /Format:Table";

                Process process = new Process();
                process.StartInfo.FileName               = dismVersion;
                process.StartInfo.Arguments              = dismArgs;
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.CreateNoWindow         = true;
                process.Start();

                var output = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                File.WriteAllText(dismOutputFile, output, Encoding.UTF8);

                var      dismChecker            = false;
                string[] dismOutputFileComparer = File.ReadAllLines(dismOutputFile);
                if (dismOutputFileComparer.Count() != tempComparer.Count())
                {
                    dismChecker = true;
                }
                else
                {
                    for (int line = 0; line < tempComparer.Length; line++)
                    {
                        if (line < dismOutputFileComparer.Length)
                        {
                            if (!tempComparer[line].Equals(dismOutputFileComparer[line]))
                            {
                                dismChecker = true;
                            }
                        }
                    }
                }

                if (dismChecker)
                {
                    IISEnablePackages(servicePath, dismOutputFile, dismVersion);
                }

                await Task.Run(() => ConfigIIS.ProlexNetSettingsAsync(installationPath, port));
            }
            catch (Exception ex)
            {
                Trace.WriteLine($"{nameof(Install)}:{nameof(IIS)}:{ex.Message}");
            }
        }