Пример #1
0
        //-----------------------------------------------------------------------------------------------------\\
        //--------------------------  Begining of Delete, Edit, Add, Enable, Disable --------------------------\\
        //-----------------------------------------------------------------------------------------------------\\

        private void IsdalMainRemove_Click(object sender, System.EventArgs e)
        {
            ClsEntriesManipulation MyClsEntriesManipulation = new ClsEntriesManipulation();

            if
            (
                !MyClsEntriesManipulation.RemoveTheEntry
                (
                    ViewMain.FocusedItem.Text,                                 // Entry Name
                    MyAction.AnalyzeIt(ViewMain.FocusedItem.SubItems[1].Text), // Entry Data
                    ViewMain.FocusedItem.SubItems[2].Text,                     // Entry Root (hkey)
                    ViewMain.FocusedItem.SubItems[4].Text,                     // EntryStatus
                    ViewMain.FocusedItem.SubItems[5].Text                      // EntryKey
                )
            )
            {
                MessageBox.Show
                    ("File No longer Exists \n no system changes occured", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            ContainerMathod(TreeMain.SelectedNode.FullPath);
        }
Пример #2
0
        private void CmdOK_Click(object sender, System.EventArgs e)
        {
            ClsAddOns MyAna = new ClsAddOns();

            DialogResult TheResult = DialogResult.None;

            if (TxtCommandAddEdit.Text == "" || TxtNameAddEdit.Text == "")
            {
                MessageBox.Show("No Changes Made " + "\n" + "\n" + "Cause: " + "Empty Field(s) Found"
                                + "\n" + "Solution: " + "Fill Both Field(s)" + "\n", "Error !",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            FileInfo CheckIfExists = new FileInfo(MyAna.AnalyzeIt(TxtCommandAddEdit.Text));

            if (!CheckIfExists.Exists)
            {
                string TheMessage =
                    "Sorry.. But We Found That The Command You Just Entered Is Not Valid" + "\n" +
                    "\"The File Does Not Exist\"" + "\n" + "\n" +
                    "Please Use The Following" + "\n" + "\n" +
                    "Press \"Abort\" if You Want To Cancel The Whole Operation And Return To The Main Window" + "\n" +
                    "Press \"Retry\" To Correct This Error And Enter A Valid Path" + "\n" +
                    "Press \"Ignore\" If You Are An Advanced User Who Knows What He Is Doing !" + "\n" + "\n" +
                    "Thank You";

                TheResult = MessageBox.Show
                                (TheMessage, "Action Needed Here", MessageBoxButtons.AbortRetryIgnore,
                                MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            switch (TheResult)
            {
            case    DialogResult.Ignore:
                this.Cmd_Test.PerformClick();
                break;

            case DialogResult.Abort:
                this.CmdCancel.PerformClick();
                break;

            default:
                this.Cmd_Test.PerformClick();
                break;
            }
        }
Пример #3
0
        internal void GetMSConfigXPRegistry()
        {
            string ThePath = @"SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg";

            try
            {
                GlobalReg = Registry.LocalMachine.OpenSubKey(ThePath, true);

                if (GlobalReg.SubKeyCount != 0)
                {
                    foreach (string SingleKey in GlobalReg.GetSubKeyNames())
                    {
                        GlobalReg = Registry.LocalMachine.OpenSubKey(ThePath + @"\" + SingleKey, true);

                        //----------------------------------------------------------------------------
                        string Entry   = GlobalReg.GetValue("item", "item").ToString();
                        string command = GlobalReg.GetValue("Command", "Command").ToString();
                        string key     = GlobalReg.GetValue("key", "key").ToString();
                        string hkey    = GlobalReg.GetValue("hkey", "hkey").ToString();
                        if (hkey == "HKLM")
                        {
                            hkey = "HKEY_LOCAL_MACHINE";
                        }
                        if (hkey == "HKCU")
                        {
                            hkey = "HKEY_CURRENT_USER";
                        }
                        //----------------------------------------------------------------------------

                        GlobalString = GlobalGet.AnalyzeIt(command);

                        GlobalEntry = new ListViewItem();

                        GlobalEntry.ImageIndex = GlobalImageCounter;
                        GlobalImageLarg.Images.Add(Icon.FromHandle(GlobalGet.AHandle(GlobalString)));
                        GlobalImageSmall.Images.Add(GlobalImageLarg.Images[GlobalImageCounter]);

                        GlobalEntry.Text = Entry;
                        GlobalEntry.SubItems.Add(command);
                        GlobalEntry.SubItems.Add(hkey);
                        GlobalEntry.SubItems.Add("Run");
                        GlobalEntry.SubItems.Add("Disabled By MSConfig.exe");
                        GlobalEntry.SubItems.Add(ThePath + @"\" + SingleKey);

                        GlobalView.Items.Add(GlobalEntry);

                        GlobalImageCounter++;
                    }
                }
            }
            catch (System.Security.SecurityException MyExp)
            {
                MessageBox.Show("Sorry Man it looks like \n" + MyExp.Message + "\n" + MyExp.GrantedSet);
                Application.ExitThread();
                Application.Exit();
            }
            catch (ArgumentNullException MyEx)
            {
                MyEx.Message.Trim();
            }
            catch (NullReferenceException MyEx)
            {
                MyEx.Message.Trim();
            }
            catch (Exception MyEx)
            {
                MyEx.Message.Trim();
            }
        }
        public bool EnableEntry
            (string EntryName, string EntryData, string EntryHkey, string WhichRun, string EntryKey)
        {
            string PathTo = "BackUps\\" + Environment.UserName;

            string PureEntryData = Hallel.AnalyzeIt(EntryData);

            string OnePath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\";

            switch (EntryHkey)
            {
            case "HKEY_LOCAL_MACHINE":
            {
                GlobalReg = Registry.LocalMachine.OpenSubKey(OnePath + WhichRun, true);
                GlobalReg.SetValue(EntryName, EntryData);
                GlobalReg.Close();

                // in msconfig xp edtion we need to delete
                // the whole key which is "EntryName"
                GlobalReg = Registry.LocalMachine.OpenSubKey(EntryKey, true);
                GlobalReg.DeleteValue(EntryName, false);
                GlobalReg.Close();

                return(true);
            }

            case "HKEY_CURRENT_USER":
            {
                GlobalReg = Registry.CurrentUser.OpenSubKey(OnePath + WhichRun, true);
                GlobalReg.SetValue(EntryName, EntryData);
                GlobalReg.Close();

                GlobalReg = Registry.CurrentUser.OpenSubKey(EntryKey, true);
                GlobalReg.DeleteValue(EntryName, false);
                GlobalReg.Close();

                return(true);
            }

            case "Startup Folder":
            {
                if (WhichRun == Environment.UserName)
                {
                    GlobalFile = new FileInfo(PureEntryData);

                    GlobalFile.Attributes = FileAttributes.Normal;
                    GlobalFile.MoveTo
                        (Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + EntryName);

                    return(true);
                }
                else if (WhichRun == "All Users")
                {
                    GlobalReg = Registry.LocalMachine.OpenSubKey
                                    (@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", true);

                    GlobalFile = new FileInfo(PureEntryData);

                    GlobalFile.Attributes = FileAttributes.Normal;
                    GlobalFile.MoveTo
                        (GlobalReg.GetValue("Common Startup", @"C:\").ToString() + @"\" + EntryName);
                    GlobalReg.Close();

                    return(true);
                }
                else                         //not All Users Or Current User
                {
                    return(false);
                }
            }

            default:                    // not HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER or  "Startup Folder"
            {
                return(false);
            }
            }
        }