private void createsimpleTasksInThisGroupToolStripMenuItem_Click(object sender, EventArgs e) { if (SelectedGroup == null) { return; } frmSimpleTasks ST = new frmSimpleTasks(SelectedGroup.Value, GroupFolders.GetFullPath(treeAction)); ST.ShowDialog(this); }
private void cmdNew_Click(object sender, EventArgs e) { frmSimpleTasks st; if (string.IsNullOrWhiteSpace(MID) == true) { st = new frmSimpleTasks(); } else { st = new frmSimpleTasks(new List <string>() { MID }); } if (st.ShowDialog(this) == DialogResult.OK) { LoadData(); } }
private void cmdEdit_Click(object sender, EventArgs e) { if (lstST.SelectedItems.Count == 0) { return; } SimpleTaskLite ST = (SimpleTaskLite)lstST.SelectedItems[0].Tag; SimpleTask stb = Program.net.GetSimpleTaskDetails(ST.ID); if (stb == null) { MessageBox.Show(this, "Cannot get Simple Tasks details: " + Program.net.GetLastError(), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } frmSimpleTasks stfrm = new frmSimpleTasks(stb); if (stfrm.ShowDialog(this) == DialogResult.OK) { LoadData(); } }
private void uninstallToolStripMenuItem_Click(object sender, EventArgs e) { if (lstApps.SelectedItems.Count == 0) { return; } List <string> MIDs = new List <string>(); if (((AddRemoveAppReport)lstApps.SelectedItems[0].Tag).IsMSI == true) { foreach (ListViewItem lst in lstApps.SelectedItems) { AddRemoveAppReport lt = (AddRemoveAppReport)lst.Tag; if (MIDs.Contains(lt.MachineID.ToLower()) == false) { MIDs.Add(lt.MachineID.ToLower()); } if (lt.IsMSI == false) { MessageBox.Show(this, "You cannot mix MSI installations with non-MSI installations to uninstall in the selection.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (MessageBox.Show(this, "Do you really want to uninstall the selected " + lstApps.SelectedItems.Count.ToString() + " application" + (lstApps.SelectedItems.Count == 1 ? "" : "s") + " from " + MIDs.Count.ToString() + " computer" + (MIDs.Count == 1 ? "" : "s") + "?", Program.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } foreach (ListViewItem lst in lstApps.SelectedItems) { AddRemoveAppReport lt = (AddRemoveAppReport)lst.Tag; if (string.IsNullOrWhiteSpace(lt.ProductID) == true) { continue; } SimpleTaskRunProgramm run = new SimpleTaskRunProgramm(); if (lt.IsWOWBranch == false) { run.Executable = "%SYSTEMROOT%\\System32\\MSIExec.exe"; } else { run.Executable = "%SYSTEMROOT%\\SysWOW64\\MSIExec.exe"; } run.Parameters = "/x " + lt.ProductID + " /passive /quiet /norestart"; run.User = lt.Username; Program.net.SetSimpleTask("Uninstall: " + lt.Name + (string.IsNullOrWhiteSpace(lt.Username) == true ? "" : " (as " + lt.Username + ")"), lt.MachineID, null, 1, run); } } else { if (lstApps.SelectedItems.Count > 1) { MessageBox.Show(this, "Only one non MSI can be selected to uninstall.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } AddRemoveAppReport lt = (AddRemoveAppReport)lstApps.SelectedItems[0].Tag; SimpleTaskRunProgramm run = new SimpleTaskRunProgramm(); if (lt.UninstallString.StartsWith("\"") == true) { if (lt.UninstallString.IndexOf('"', 1) == -1) { run.Executable = lt.UninstallString.Substring(1); } else { run.Executable = lt.UninstallString.Substring(1, lt.UninstallString.IndexOf('"', 1) - 1); run.Parameters = lt.UninstallString.Substring(lt.UninstallString.IndexOf('"', 1) + 1); } run.User = lt.Username; } else { if (lt.UninstallString.IndexOf(' ', 0) == -1) { run.Executable = lt.UninstallString; } else { run.Executable = lt.UninstallString.Substring(0, lt.UninstallString.IndexOf(' ')); run.Parameters = lt.UninstallString.Substring(lt.UninstallString.IndexOf(' ') + 1); } run.User = lt.Username; } SimpleTask st = new SimpleTask(); st.Data = JsonConvert.SerializeObject(run); st.MachineID = lt.MachineID; st.Type = 1; st.ID = -1; st.Name = "Uninstall: " + lt.Name + (string.IsNullOrWhiteSpace(lt.Username) == true ? "" : " (as " + lt.Username + ")"); frmSimpleTasks frm = new frmSimpleTasks(st); frm.ShowDialog(this); } }