예제 #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("לא ניתן להסיר באמצעות סיסמה שגויה");
                }
            }
        }
예제 #2
0
 protected override void OnBeforeInstall(IDictionary savedState)
 {
     base.OnBeforeInstall(savedState);
     try
     {
         string servicePath = Assembly.GetExecutingAssembly().CodeBase;
         servicePath = servicePath.Replace("MMB-Filter.exe", "MMB-Service.exe");
         ServiceAdapter.InstallService(servicePath);
         ServiceAdapter.StartService("GUIAdapter", 10000);
     }
     catch
     {
         MessageBox.Show("לא ניתן להתקין תוסף שירות");
     }
 }
예제 #3
0
        private void exitButton_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("יציאה תוביל לסגירה מלאה של המערכת ולהשבתת הסינון" + Environment.NewLine + "האם אתה בטוח שברצונך לצאת?", "יציאה", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialogResult == DialogResult.Yes)
            {
                exitButton.Text = "יוצא....";
                CustomNotifyIcon.hide();
                if (ServiceAdapter.GetServiceStatus("GUIAdapter") == "Running")
                {
                    ServiceAdapter.StopService("GUIAdapter", 10000);
                    while (ServiceAdapter.GetServiceStatus("GUIAdapter") != "Stopped")
                    {
                        exitButton.Text = ServiceAdapter.GetServiceStatus("GUIAdapter");
                        ServiceAdapter.StopService("GUIAdapter", 10000);
                        System.Threading.Thread.Sleep(3000);
                    }
                }
                InternetBlocker.block(false);
                Application.ExitThread();
            }
        }
예제 #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);


            //Start by looking for administrator privilege
            if (IsAdmin())
            {
                //If administrator privilege is granted

                //close the current proceess if same process already opened.
                if (Environment.GetCommandLineArgs().Length > 1)
                {
                    if (Environment.GetCommandLineArgs()[0] != "runAgainAsAdmin")
                    {
                        if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1)
                        {
                            System.Diagnostics.Process.GetCurrentProcess().Kill();
                        }
                    }
                }

                // setup to custom font.
                SetupFont();

                //add the app to startup applications.
                TaskingSchedule.RunOnStartup("MMB", Application.StartupPath + "\\" + System.AppDomain.CurrentDomain.FriendlyName);

                //run the app service
                ServiceAdapter.StartService("GUIAdapter", 10000);

                //setup global menuForm.
                menuForm = new MenuForm();

                //check if this is the first time the app is opening on this computer.
                if (IsFirstOpening())
                {
                    ActAsFirstOpening();
                }

                //setup the filtering system.
                FilteringSystem.Setup();

                //start new menu form.
                Application.Run(menuForm);
            }
            else //
            {
                //If administrator privilege not granted, run again as administrator
                if (StartAgainAsAdmin())
                {
                    //By opening a new administrator-privileged process, close the current process.
                    Application.ExitThread();
                }
                else
                {
                    //If the second attempt of opening as an administrator permission failed, Block the Internet (by the service) and close the current procees.
                    ServiceAdapter.StartInternetBlocking();
                    MessageBox.Show("אפליקציה זו חייבת לרוץ כמנהל, האינטרנט מושבת.", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                    Application.Exit();
                }
            }
        }