Пример #1
0
        public void CreateIntegration(bool silent)
        {
            try
            {
                string command_str_file_assoc = AppDomain.CurrentDomain.BaseDirectory + "EasyRun.exe --add-file \"%1\"";
                string command_str_dir_assoc  = AppDomain.CurrentDomain.BaseDirectory + "EasyRun.exe --add-dir \"%1\"";


                if (DeleteIntegration() == 0)
                {
                    //creating file assoc
                    expl.CreateAssociation("*", KeyName, command_str_file_assoc, "Add as EasyRun shortcut", AppDomain.CurrentDomain.BaseDirectory + "EasyRun.exe");

                    //creating directory assoc
                    expl.CreateAssociation("Directory", KeyName, command_str_dir_assoc, "Add as EasyRun shortcut", AppDomain.CurrentDomain.BaseDirectory + "EasyRun.exe");

                    if (!silent)
                    {
                        msg.ShowMessage("Explorer Integration has been enabled successfully");
                    }
                }
                else
                {
                    msg.ShowWarning("The requested operation failed. an error occured while trying to unregistering handlers.");
                }
            }
            catch (Exception ex)
            {
                msg.ShowError(ex.Message);
            }
        }
Пример #2
0
 private void Button3_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog ofd = new OpenFileDialog()
         {
             CheckFileExists = true,
             FileName        = "",
             Title           = "Open"
         };
         DialogResult resl = ofd.ShowDialog();
         if (resl == DialogResult.OK)
         {
             res robj = new res();
             exec          = ofd.FileName;
             loc           = robj.getLocation(exec);
             type          = robj.getExtension(exec);
             filename      = robj.getFileName(exec);
             textBox1.Text = exec;
         }
     }
     catch (Exception ex)
     {
         msg.ShowError(ex.Message);
     }
 }
Пример #3
0
        public editConfig(string aliasObj, string targetObj, string regkeyObj, aliases child)
        {
            try
            {
                InitializeComponent();


                msg = new UDialogs();

                textBox1.KeyDown += new KeyEventHandler(RetKey);
                textBox2.KeyDown += new KeyEventHandler(RetKey);

                this.alias    = aliasObj;
                this.target   = targetObj;
                this.regkey   = regkeyObj;
                textBox1.Text = alias;
                textBox2.Text = target;
                this.Text     = "Edit " + alias;
                if (regkey.Contains("HKEY_CURRENT_USER"))
                {
                    access = "HKCU";
                }
                else if (regkey.Contains("HKEY_LOCAL_MACHINE"))
                {
                    access = "HKLM";
                }
                this.inst        = child;
                inst.editDropped = 0;
            }
            catch (Exception ex)
            {
                msg.ShowError(ex.Message);
            }
        }
Пример #4
0
 public about()
 {
     try
     {
         InitializeComponent();
         x                    = new Form1();
         msg                  = new UDialogs();
         label1.Text          = x.appname;
         label2.Text          = "version " + x.version;
         label5.Text          = x.copyright;
         this.FormBorderStyle = FormBorderStyle.FixedSingle;
         this.MinimizeBox     = false;
         this.MaximizeBox     = false;
         this.StartPosition   = FormStartPosition.CenterScreen;
         this.ShowIcon        = false;
         this.ShowInTaskbar   = false;
         this.Text            = "About";
         button1.Select();
         // this.Size = new System.Drawing.Size(280, 130);
     }
     catch (Exception ex)
     {
         msg.ShowError(ex.Message);
     }
 }
Пример #5
0
        public UACDelegate()
        {
            try
            {
                InitializeComponent();

                msg = new UDialogs();
                this.SAFE_LOCATION_DIRECTORY = new Form1().SAFE_LOCATION_DIRECTORY;
                textBox1.KeyDown            += new KeyEventHandler(RetKey);
                textBox2.KeyDown            += new KeyEventHandler(RetKey);
                textBox3.KeyDown            += new KeyEventHandler(RetKey);
                textBox4.KeyDown            += new KeyEventHandler(RetKey);
                checkBox2.KeyDown           += new KeyEventHandler(RetKey);
                checkBox1.KeyDown           += new KeyEventHandler(RetKey);
            }
            catch (Exception ex)
            {
                msg.ShowError(ex.Message);
            }
        }
Пример #6
0
 public string getExtension(string path)
 {
     try
     {
         if (File.Exists(path))
         {
             return(path.Substring(path.LastIndexOf(".") + 1));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         msg.ShowError(ex.Message);
         return(null);
     }
 }
Пример #7
0
        public void CreateFileShortcut(string alias_p, string filepath_p)
        {
            this.SAFE_LOCATION_DIRECTORY = new Form1().SAFE_LOCATION_DIRECTORY;
            this.alias    = alias_p;
            this.filepath = filepath_p;
            try
            {
                try
                {
                    if (alias.Contains(".") == false || alias.Substring(alias.LastIndexOf(".")) != ".exe")
                    {
                        alias += ".exe";
                    }
                    string alias_obj   = (string)Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + alias).GetValue("");
                    string regexSearch = new string(Path.GetInvalidPathChars());
                    Regex  r           = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
                    alias_obj = r.Replace(alias_obj, "");
                    FileVersionInfo inf = FileVersionInfo.GetVersionInfo(alias_obj);
                    DialogResult    res = msg.ConfirmAction("A shortcut with the name you specified already exists" + "\n\nDetails\n-------\nAlias: " + alias + "\nFile: " + alias_obj.Substring(alias_obj.LastIndexOf(@"\") + 1) + "\nDescription: " + inf.FileDescription + "\nLocation: " + alias_obj + "\n\nWould you like to overwrite it?");

                    if (res == DialogResult.Yes)
                    {
                        targetImage = filepath;
                        WriteAlias();
                    }
                }

                catch (NullReferenceException excep)
                {
                    /*  DialogResult re = MessageBox.Show("Confirm new shortcut:\n\nDetails\n------\nNew Alias:  " + alias + "\n\nTarget:  " + filepath +  "\n\nWould you like to proceed?", "Confirm Settings", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                     * if (re == DialogResult.OK)
                     * {*/
                    targetImage = filepath;
                    WriteAlias();
                    /* }*/
                }
            }
            catch (Exception ex)
            {
                msg.ShowError(ex.Message);
            }
        }
Пример #8
0
        private void ClickBait()
        {
            try
            {
                if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
                {
                    msg.ShowWarning("One or more required fields is missing values");
                }
                else if (textBox1.Text == alias && textBox2.Text == target)
                {
                    inst.editDropped = 1; //bail immediately cause no changes

                    this.Close();
                }
                else if (textBox1.Text.Contains(" "))
                {
                    msg.ShowWarning("Alias cannot be empty or contain white spaces.");
                }
                else
                {
                    if (textBox1.Text.Contains(".") == false || textBox1.Text.Substring(textBox1.Text.LastIndexOf(".")) != ".exe")
                    {
                        textBox1.Text = textBox1.Text + ".exe";
                    }
                    newalias  = textBox1.Text;
                    newtarget = textBox2.Text;
                    var resul = msg.ConfirmAction("Are you sure you want to confirm changes?");
                    if (resul == DialogResult.Yes)
                    {
                        if (access == "HKLM")
                        {
                            Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + newalias).Close();
                            Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + newalias, true).SetValue("", newtarget);
                            Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + newalias, true).SetValue("Path", newtarget.Substring(0, newtarget.LastIndexOf(@"\")) + @"\");
                            if (newalias != alias)
                            {
                                Registry.LocalMachine.DeleteSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\" + alias, false);
                            }

                            result           = 1;
                            inst.editDropped = 0; //trigger list refresh
                            this.Close();
                        }
                        else if (access == "HKCU")
                        {
                            Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + newalias).Close();
                            Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + newalias, true).SetValue("", newtarget);
                            Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + newalias, true).SetValue("Path", newtarget.Substring(0, newtarget.LastIndexOf(@"\")) + @"\");
                            if (newalias != alias)
                            {
                                Registry.CurrentUser.DeleteSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\" + alias, false);
                            }

                            result           = 1;
                            inst.editDropped = 0; //trigger list refresh

                            this.Close();
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                msg.ShowError(exp.Message);
            }
        }
Пример #9
0
        public Form1()
        {
            //  new FailSafeInit().CheckFailSafe();
            InitializeComponent();

            try
            {
                this.Text = appname;



                textBox1.KeyDown += new KeyEventHandler(ExpressionHandler);
                textBox2.KeyDown += new KeyEventHandler(ExpressionHandler);
                textBox3.KeyDown += new KeyEventHandler(ExpressionHandler);

                radioButton1.KeyDown += new KeyEventHandler(ExpressionHandler);
                radioButton2.KeyDown += new KeyEventHandler(ExpressionHandler);
                radioButton3.KeyDown += new KeyEventHandler(ExpressionHandler);
                radioButton4.KeyDown += new KeyEventHandler(ExpressionHandler);

                checkBox2.KeyDown += new KeyEventHandler(ExpressionHandler);
                checkBox3.KeyDown += new KeyEventHandler(ExpressionHandler);
            }
            catch (Exception ex)
            {
                msg.ShowError(ex.Message);
            }



            /*
             * try
             * {
             *  if (!Directory.Exists(SAFE_LOCATION_DIRECTORY))
             *      Directory.CreateDirectory(SAFE_LOCATION_DIRECTORY);
             * }
             * catch (Exception ex)
             * {
             *  msg.ShowError(ex.Message);
             * }
             */
        }
Пример #10
0
        static void Main(String [] args)
        {
            //checking for 4libraries in the executing assembly location
            //when adding new libraries in Form1, rem to perform checks for fail-safe run in the below snippet

            new FailSafeInit().CheckFailSafe();


            UDialogs msg = new UDialogs();

            try
            {
                var      options = new Options();
                UDialogs x       = new UDialogs();

                if (CommandLine.Parser.Default.ParseArguments(args, options))
                {
                    if (options.filePath != null)
                    {
                        CommandLineHandler cmdHndl = new CommandLineHandler();
                        cmdHndl.askUser("Enter alias: (example: apple)", false, "Create file shortcut - EasyRun");
                        if (!String.IsNullOrEmpty(cmdHndl.userInput) && !cmdHndl.userInput.Contains(" "))
                        {
                            cmdHndl.CreateFileShortcut(cmdHndl.userInput, options.filePath);
                        }
                    }
                    else if (options.dirPath != null)
                    {
                        CommandLineHandler cmdHndl = new CommandLineHandler();
                        cmdHndl.askUser("Enter alias: (example: cats)", true, "Create directory shortcut - EasyRun");
                        if (!String.IsNullOrEmpty(cmdHndl.userInput) && !cmdHndl.userInput.Contains(" "))
                        {
                            cmdHndl.CreateDirectoryShortcut(cmdHndl.userInput, options.dirPath);
                        }
                    }
                    else if (options.enable == true)
                    {
                        new ExplorerIntegration().CreateIntegration(false);
                        Application.Exit();
                    }
                    else if (options.removeIntegration == true)
                    {
                        new ExplorerIntegration().DeleteIntegration();
                        //  msg.ShowMessage("Removed Integration");
                        Application.Exit();
                    }

                    else
                    {
                        try
                        {
                            Application.EnableVisualStyles();
                            Application.SetCompatibleTextRenderingDefault(false);
                            Application.Run(new Form1());
                        }
                        catch (Exception ex)
                        {
                            msg.ShowError(ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                msg.ShowError(ex.Message);
            }
        }
Пример #11
0
 public aliases()
 {
     try
     {
         InitializeComponent();
         this.SAFE_LOCATION_DIRECTORY = new Form1().SAFE_LOCATION_DIRECTORY;
     }
     catch (Exception ex)
     {
         msg.ShowError(ex.Message);
     }
 }