예제 #1
0
        /// <summary>
        /// Install and setup.
        /// </summary>
        /// <param name="checkResult"></param>
        /// <returns></returns>
        public static bool Install([param: NotNull] Func <Func <bool>, string, string, bool> checkResult)
        {
            if (checkResult is null)
            {
                throw new ArgumentNullException(nameof(checkResult));
            }
            LogHelper.Debug("EnableProgram");
            if (IsNotifierTaskInstalled())
            {
                RemoveNotifierTask();  // will be re-created below
            }

            if (Settings.Default.StartNotifierAfterLogin)
            {
                if (!checkResult(() => CreateNotifierTask(), "Notifier will start after next windows login", Resources.MSG_INST_TASK_ERR))
                {
                    return(false);
                }
            }

            if (!checkResult(() => (ProcessHelper.GetProcessFeedback(
                                        Environment.SystemDirectory
                                        + "\\reg.exe", @"ADD HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v SCENoApplyLegacyAuditPolicy /t REG_DWORD /d 1 /f"))
                             , "Registry enable SCENoApplyLegacyAuditPolicy."
                             , Resources.MSG_INST_ENABLE_LOG_ERR))
            {
                return(false);
            }

            if (!checkResult(() => SetAuditPolConnection(enableSuccess: Settings.Default.AuditPolEnableSuccessEvent, enableFailure: true)
                             , "Audit policy enabled."
                             , Resources.MSG_INST_ENABLE_LOG_ERR))
            {
                return(false);
            }

            if (!checkResult(() => FirewallHelper.EnableWindowsFirewall()
                             , "Windows firewall enabled."
                             , Resources.MSG_INST_ENABLE_FW_ERR))
            {
                return(false);
            }

            if (!checkResult(() => CreateDefaultRules()
                             , Resources.MSG_INST_OK
                             , "Unable to create the default windows firewall rules."))
            {
                return(false);
            }

            Settings.Default.IsInstalled = true;
            Settings.Default.Save();

            return(true);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pass"></param>
        /// <returns></returns>
        public static bool EnableProgram(bool allUsers, Action <bool, string> callback)
        {
            if (IsInstalled())
            {
                RemoveTask();  // will be re-created below
            }

            if (ProcessHelper.getProcessFeedback(Environment.SystemDirectory + "\\reg.exe", @"ADD HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v SCENoApplyLegacyAuditPolicy /t REG_DWORD /d 1 /f") &&
                SetAuditPolConnection(enableSuccess: Settings.Default.AuditPolEnableSuccessEvent, enableFailure: true)
                )
            {
                if (FirewallHelper.EnableWindowsFirewall())
                {
                    if (CreateDefaultRules())
                    {
                        if (createTask(allUsers))
                        {
                            callback(true, Resources.MSG_INST_OK);
                        }
                        else
                        {
                            callback(false, Resources.MSG_INST_TASK_ERR);
                            return(false);
                        }
                    }
                    else
                    {
                        callback(false, "Unable to create the default rules, please consider reactivating WFN.");
                        return(false);
                    }
                }
                else
                {
                    callback(false, Resources.MSG_INST_ENABLE_FW_ERR);
                    return(false);
                }
            }
            else
            {
                callback(false, Resources.MSG_INST_ENABLE_LOG_ERR);
                return(false);
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pass"></param>
        /// <returns></returns>
        public static bool EnableProgram(bool allUsers, Action <bool, string> callback)
        {
            if (IsInstalled())
            {
                RemoveTask();
            }

            if (ProcessHelper.getProcessFeedback(Environment.SystemDirectory + "\\reg.exe", @"ADD HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v SCENoApplyLegacyAuditPolicy /t REG_DWORD /d 1 /f") &&
                ProcessHelper.getProcessFeedback(Environment.SystemDirectory + "\\auditpol.exe", "/set /subcategory:{0CCE9226-69AE-11D9-BED3-505054503030} /failure:enable /success:disable"))
            {
                if (FirewallHelper.EnableWindowsFirewall())
                {
                    if (CreateDefaultRules())
                    {
                        if (createTask(allUsers))
                        {
                            callback(true, Resources.MSG_INST_OK);
                        }
                        else
                        {
                            callback(false, Resources.MSG_INST_TASK_ERR);
                            return(false);
                        }
                    }
                    else
                    {
                        callback(false, "Unable to create the default rules, please consider reactivating WFN.");
                        return(false);
                    }
                }
                else
                {
                    callback(false, Resources.MSG_INST_ENABLE_FW_ERR);
                    return(false);
                }
            }
            else
            {
                callback(false, Resources.MSG_INST_ENABLE_LOG_ERR);
                return(false);
            }

            return(true);
        }