Example #1
0
 internal static void RemoveAssemblyFromFirewallExceptions(string name, string fullPath, Task.TaskErrorLoggingDelegate errorHandler)
 {
     if (string.IsNullOrEmpty(fullPath))
     {
         return;
     }
     if (ConfigurationContext.Setup.IsLonghornServer)
     {
         string args = string.Format("advfirewall firewall delete rule name=\"{0}\" program=\"{1}\"", name, fullPath);
         ManageService.RunNetShProcess(args, errorHandler);
     }
 }
Example #2
0
        protected void Uninstall()
        {
            TaskLogger.LogEnter();
            if (!ServiceControllerUtils.IsInstalled(this.Name))
            {
                base.WriteVerbose(Strings.ServiceNotInstalled(this.Name));
                return;
            }
            base.WriteVerbose(Strings.WillUninstallInstalledService(this.Name));
            try
            {
                this.serviceProcessInstaller.Uninstall(null);
            }
            catch (Win32Exception ex)
            {
                if (ex.NativeErrorCode == 1060)
                {
                    this.WriteWarning(Strings.ServiceAlreadyNotInstalled(this.Name));
                }
                else
                {
                    base.WriteError(new ServiceUninstallFailureException(this.Name, ex.Message, ex), ErrorCategory.InvalidOperation, null);
                }
            }
            catch (InstallException ex2)
            {
                base.WriteError(new ServiceUninstallFailureException(this.Name, ex2.Message, ex2), ErrorCategory.InvalidOperation, null);
            }
            if (this.serviceFirewallRules.Count > 0)
            {
                using (List <ExchangeFirewallRule> .Enumerator enumerator = this.serviceFirewallRules.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ExchangeFirewallRule exchangeFirewallRule = enumerator.Current;
                        TaskLogger.Trace("Removing Windows Firewall Rule for Service {0}", new object[]
                        {
                            this.Name
                        });
                        exchangeFirewallRule.Remove();
                    }
                    return;
                }
            }
            string fullPath = this.serviceProcessInstaller.Context.Parameters["assemblypath"];

            TaskLogger.Trace("Removing Service {0} from windows firewall exception", new object[]
            {
                this.Name
            });
            ManageService.RemoveAssemblyFromFirewallExceptions(this.Name, fullPath, new Task.TaskErrorLoggingDelegate(base.WriteError));
            TaskLogger.LogExit();
        }
Example #3
0
 internal static void AddAssemblyToFirewallExceptions(string name, string fullPath, Task.TaskErrorLoggingDelegate errorHandler)
 {
     if (string.IsNullOrEmpty(fullPath) || string.IsNullOrEmpty(name))
     {
         return;
     }
     if (ConfigurationContext.Setup.IsLonghornServer)
     {
         string args = string.Format("advfirewall firewall add rule name=\"{0}\" dir=in action=allow program=\"{1}\" localip=any remoteip=any profile=any Enable=yes", name, fullPath);
         ManageService.RunNetShProcess(args, errorHandler);
     }
 }