public RESTStatus GetStartupItems(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } StartupsRep = new ListStartupItemReport(); StartupsRep.Items = new List <StartupItemFull>(); lock (ni.sqllock) { SqlDataReader dr; if (string.IsNullOrWhiteSpace(id) == true) { dr = sql.ExecSQLReader("select * from Startups inner join ComputerAccounts on ComputerAccounts.MachineID=Startups.MachineID left outer join UsersList on UsersList.SID=HKCUUser AND UsersList.MachineID=Startups.MachineID order by Location,[Key]"); } else { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } dr = sql.ExecSQLReader("select * from Startups inner join ComputerAccounts on ComputerAccounts.MachineID=Startups.MachineID left outer join UsersList on UsersList.SID=HKCUUser AND UsersList.MachineID=Startups.MachineID WHERE ComputerAccounts.MachineID=@m order by Location,[Key]", new SQLParam("@m", id)); } while (dr.Read()) { StartupItemFull ar = new StartupItemFull(); ar.Computername = Convert.ToString(dr["Computername"]); ar.DT = SQLLib.GetDTUTC(dr["DT"]); ar.HKCUUser = Convert.ToString(dr["HKCUUser"]); ar.MachineID = Convert.ToString(dr["MachineID"]); ar.Username = Convert.ToString(dr["Username"]); ar.Item = Convert.ToString(dr["Item"]); ar.Key = Convert.ToString(dr["Key"]); ar.Location = Convert.ToString(dr["Location"]); StartupsRep.Items.Add(ar); } dr.Close(); } return(RESTStatus.Success); }
private void removeEntryToolStripMenuItem_Click(object sender, EventArgs e) { if (lstStart.SelectedItems.Count == 0) { return; } if (MessageBox.Show(this, "Do you want to remove the selected " + lstStart.SelectedItems.Count.ToString() + " entr" + (lstStart.SelectedItems.Count == 1 ? "y" : "ies") + "?", Program.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } foreach (ListViewItem lst in lstStart.SelectedItems) { StartupItemFull start = (StartupItemFull)lst.Tag; SimpleTaskRegistry reg = new SimpleTaskRegistry(); if (string.IsNullOrWhiteSpace(start.HKCUUser) == false) { reg.Root = 1; //HKCU reg.Folder = start.HKCUUser + "\\"; } else { reg.Root = 0; //HKLM reg.Folder = ""; } switch (start.Location.ToLower()) { case "reg": reg.Folder += "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; break; case "reg_wow": reg.Folder += "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"; break; default: continue; } reg.Action = 1; reg.Valuename = start.Key == "(Default)" ? "" : start.Key; Program.net.SetSimpleTask("Removing Startup Item: " + start.Key + (string.IsNullOrWhiteSpace(start.Username) == true ? "" : " (as " + start.Username + ")"), start.MachineID, null, 2, reg); } }
public frmPropertiesWindow(StartupItemFull cd) { InitializeComponent(); data = cd; }