Esempio n. 1
0
        protected override void OnBeforeUninstall(IDictionary savedState)
        {
            base.OnBeforeInstall(savedState);

            //Prevent uninstalling while the app is on
            if (!IsAllAppClosed("MMB-Filter"))
            {
                MessageBox.Show("לפני הסרת התקנה יש לסגור את המערכת. סגור את המערכת ולאחר מכן נסה שנית.");
                throw new ApplicationException("לא ניתן להסיר את התוכנה בזמן שאחד המופעים שלה פתוח");
            }

            installingProcess = false;

            //ask for password
            Dialogs.EnterPassword enterPassword = new Dialogs.EnterPassword("על מנת להסיר את ההתקנה יש להזין סיסמת מנהל", true);
            DialogResult          dialogResult  = enterPassword.ShowDialog();

            enterPassword.BringToFront();

            if (dialogResult == DialogResult.OK)
            {
                string gettedPass = enterPassword.gettedText;
                if (gettedPass == PasswordEncryption.Decrypt(Installer.GetUninstallingPass()) || FilteringSystem.IsAdminPassword(gettedPass))
                {
                    string localDataPath = Environment.ExpandEnvironmentVariables("%localappdata%") + @"\MMB\";

                    try
                    {
                        //Delete the appData
                        Directory.Delete(localDataPath, true);
                    }
                    catch
                    {}
                    //Set dhcp dns
                    DnsController.setMode(false);

                    //Stop the internt blocker service
                    ServiceAdapter.StopService("GUIAdapter", 10000);

                    //Uninstall the Service
                    string servicePath = Assembly.GetExecutingAssembly().CodeBase;
                    servicePath = servicePath.Replace("MMB-Filter.exe", "MMB-Service.exe");
                    ServiceAdapter.UninstallService(servicePath);

                    //realese the internet blocking
                    InternetBlocker.block(false);

                    MessageBox.Show("הסרת ההתקנה הסתיימה", "לוקחים אחריות", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.ServiceNotification);
                }
                else
                {
                    MessageBox.Show("הסיסמה שגויה, התראה נשלחה למנהל המערכת", "לוקחים אחריות", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    throw new ApplicationException("לא ניתן להסיר באמצעות סיסמה שגויה");
                }
            }
        }
Esempio n. 2
0
 private static void UpdateSettingsFunction()
 {
     HostsFileCatcher.WriteSettings();
     if (IsOn())
     {
         DnsController.setMode(Resources.profile.Default.safe_server);
         HostsFileCatcher.StartCatching();
     }
     else
     {
         HostsFileCatcher.ReleaseCatch();
         DnsController.setMode(false);
     }
 }
Esempio n. 3
0
 public static void UpdateSettings()
 {
     //Thread thr = new Thread(new ThreadStart(UpdateSettingsFunction));
     //thr.Start();
     HostsFileCatcher.WriteSettings();
     if (IsOn())
     {
         DnsController.setMode(Resources.profile.Default.safe_server);
         HostsFileCatcher.StartCatching();
     }
     else
     {
         HostsFileCatcher.ReleaseCatch();
         DnsController.setMode(false);
     }
 }