private void Form1_Load(object sender, EventArgs e) { try { IsWinXP(); textBox3.Hide(); button3.Hide(); label6.Hide(); radioButton3.Text += username; if (isxp == true) { checkBox3.Hide(); } //new ExplorerIntegration().CreateIntegration(); if (new ExplorerIntegration().IntegrationEnabled()) { enableToolStripMenuItem.Checked = true; disableToolStripMenuItem.Checked = false; } else { enableToolStripMenuItem.Checked = false; disableToolStripMenuItem.Checked = true; } if (new ExplorerIntegration().IntegrationCorrupt()) { if (msg.ConfirmAction("The explorer integration module is corrupt. would you like to fix it?") == DialogResult.Yes) { new ExplorerIntegration().CreateIntegration(false); } } textBox2.Select(); } catch (Exception ex) { msg.ShowError(ex.Message); } }
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); } }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Escape) { UDialogs t = new UDialogs(); if (t.ConfirmAction("Are you sure you want to exit?") == DialogResult.Yes) { this.Close(); return(true); } return(false); } return(base.ProcessCmdKey(ref msg, keyData)); }
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); } }
private void Act() { try { if (!Directory.Exists(SAFE_LOCATION_DIRECTORY)) { Directory.CreateDirectory(SAFE_LOCATION_DIRECTORY); } if (string.IsNullOrEmpty(textBox1.Text) || !System.IO.File.Exists(textBox1.Text)) { msg.ShowWarning("One or more required fields are missing values"); } else if (checkBox2.Checked == true && string.IsNullOrEmpty(textBox4.Text)) { msg.ShowWarning("Alias cannot be empty or contain spaces"); } else if (checkBox2.Checked == true && textBox4.Text.Contains(" ")) { msg.ShowWarning("Alias cannot be empty or contain spaces"); } else { var resul = msg.ConfirmAction("Do you want to confirm changes?"); if (resul == DialogResult.Yes) { propargs = textBox2.Text; wdir = textBox3.Text; TaskService tsObj = new TaskService(); TaskDefinition tsDef = tsObj.NewTask(); tsDef.Principal.RunLevel = TaskRunLevel.Highest; tsDef.Actions.Add(new ExecAction(exec, propargs, wdir)); tsDef.Settings.AllowDemandStart = true; tsDef.RegistrationInfo.Author = "EasyRun"; tsDef.RegistrationInfo.Description = "Allows creation of Trusted UAC Shortcuts by the user"; tsDef.Principal.DisplayName = filename; tsDef.Settings.AllowHardTerminate = true; tsDef.Settings.DisallowStartIfOnBatteries = false; tsDef.Settings.MultipleInstances = TaskInstancesPolicy.StopExisting; tsDef.Settings.Enabled = true; tsDef.Settings.StopIfGoingOnBatteries = false; tsDef.Settings.WakeToRun = true; tskname = "EasyRun-" + filename; tsObj.RootFolder.RegisterTaskDefinition("EasyRun-" + filename, tsDef); if (addsh == true) { string x = "\"" + tskname + "\""; string cmd = "@echo off" + Environment.NewLine + @"C:\Windows\System32\schtasks.exe /run /tn " + x + Environment.NewLine + "exit"; EasyRun.res x1 = new EasyRun.res(); tskname = x1.removeExtension(tskname); tskname += ".cmd"; string cmd_file = SAFE_LOCATION_DIRECTORY + tskname; System.IO.File.WriteAllText(cmd_file, cmd); action_file_selected_path = cmd_file; location_temp = x1.getLocation(cmd_file); WshShellClass wsh = new WshShellClass(); IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + tskname + ".lnk") as IWshRuntimeLibrary.IWshShortcut; shortcut.Description = "EasyRun Trusted UAC Bypass shortcut for " + tskname; shortcut.WindowStyle = 1; shortcut.TargetPath = action_file_selected_path; shortcut.Save(); } if (checkBox2.Checked) { tskname = "EasyRun-" + filename; alias = textBox4.Text; alias += ".exe"; string x = "\"" + tskname + "\""; string cmd = "@echo off" + Environment.NewLine + @"C:\Windows\System32\schtasks.exe /run /tn " + x + Environment.NewLine + "exit"; EasyRun.res x1 = new EasyRun.res(); tskname = x1.removeExtension(tskname); tskname += ".cmd"; string cmd_file = SAFE_LOCATION_DIRECTORY + tskname; System.IO.File.WriteAllText(cmd_file, cmd); action_file_selected_path = cmd_file; location_temp = x1.getLocation(cmd_file); try { string EXISTING_ALIAS_FILEMAPPED = (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))); EXISTING_ALIAS_FILEMAPPED = r.Replace(EXISTING_ALIAS_FILEMAPPED, ""); FileVersionInfo inf = FileVersionInfo.GetVersionInfo(EXISTING_ALIAS_FILEMAPPED); DialogResult res = msg.ConfirmAction("A shortcut already exists with the name: " + alias + "\n\nDetails\n-------\nAlias: " + alias + "\n\nDescription: " + inf.FileDescription + "\nFile: " + EXISTING_ALIAS_FILEMAPPED.Substring(EXISTING_ALIAS_FILEMAPPED.LastIndexOf(@"\") + 1) + "\nPath: " + EXISTING_ALIAS_FILEMAPPED + "\n\nWould you like to overwrite it?"); if (res == DialogResult.Yes) { FileVersionInfo ins = FileVersionInfo.GetVersionInfo(action_file_selected_path); Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + alias).Close(); Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + alias, true).SetValue("", action_file_selected_path); Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + alias, true).SetValue("Path", location_temp + @"\"); msg.ShowMessage("Success!"); return; } } catch (NullReferenceException excep) { FileVersionInfo ins = FileVersionInfo.GetVersionInfo(action_file_selected_path); DialogResult re = msg.ConfirmAction("Confirm new shortcut:\n\nDetails\n------\nNew Alias: " + alias + "\n\nFile: " + action_file_selected_path + "\nDescription: " + ins.FileDescription + "\nPath: " + location_temp + "\n\nWould you like to proceed?"); if (re == DialogResult.Yes) { Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + alias).Close(); Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + alias, true).SetValue("", action_file_selected_path); Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + alias, true).SetValue("Path", location_temp + @"\"); msg.ShowMessage("Success!"); return; } } } msg.ShowMessage("Success!"); } } } catch (Exception exp) { msg.ShowError(exp.Message); } }
private void DelItem() { try { if (listView1.SelectedItems.Count > 0) { string ALIAS = null; string target = null; string description = null; string filename = null; using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\" + listView1.SelectedItems[0].Text)) { if (key != null) { ALIAS = listView1.SelectedItems[0].Text; target = (string)key.GetValue(""); FileVersionInfo ab = FileVersionInfo.GetVersionInfo(target); description = ab.FileDescription; filename = target.Substring(target.LastIndexOf(@"\") + 1); DialogResult re = msg.ConfirmAction("Details\n-------\nAlias: " + ALIAS + "\nFilename: " + filename + "\nDescription: " + description + "\nPath: " + target + "\n\nAre you sure you want to delete this item?"); if (re == DialogResult.Yes) { Registry.LocalMachine.DeleteSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\" + listView1.SelectedItems[0].Text, false); // MessageBox.Show("Success!", "EasyRun", MessageBoxButtons.OK, MessageBoxIcon.Information); RefreshList(); } } else { using (RegistryKey keyhkcu = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\" + listView1.SelectedItems[0].Text)) { if (keyhkcu != null) { ALIAS = listView1.SelectedItems[0].Text; target = (string)key.GetValue(""); FileVersionInfo ab = FileVersionInfo.GetVersionInfo(target); description = ab.FileDescription; filename = target.Substring(target.LastIndexOf(@"\") + 1); DialogResult re = msg.ConfirmAction("Details\n-------\nAlias: " + ALIAS + "\nFilename: " + filename + "\nDescription: " + description + "\nPath: " + target + "\n\nAre you sure you want to delete this item"); if (re == DialogResult.Yes) { Registry.CurrentUser.DeleteSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\" + listView1.SelectedItems[0].Text, false); // MessageBox.Show("Success!", "EasyRun", MessageBoxButtons.OK, MessageBoxIcon.Information); RefreshList(); } } else { msg.ShowWarning("Failed to delete item " + ALIAS); } } } } } } catch (Exception exp) { msg.ShowError(exp.Message); } }