07-04-2011, 06:47 PM
An interesting function if you want to avoid new programs to be added to windows startup :
In the exemple it just shows a messagebox with the infos of the program added to startup (path and method). You can do what you want with the results (delete registry key, delete binary...).
Code:
public void FillStartUpList()
{
var mangnmt = new ManagementClass("Win32_StartupCommand");
ManagementObjectCollection mcol = mangnmt.GetInstances();
foreach (ManagementObject strt in mcol)
{
StartUpList.Add(strt["Command"] + " Method : " + strt["Location"]);
}
}
public void StartUpTimer()
{
MyTimer.Tick += CheckStartUpList;
// Sets the timer interval to 5 seconds.
MyTimer.Interval = 5000;
MyTimer.Start();
}
public void CheckStartUpList(Object myObject, EventArgs myEventArgs)
{
var mangnmt = new ManagementClass("Win32_StartupCommand");
var mcol = mangnmt.GetInstances();
foreach (ManagementObject strt in mcol)
{
NewStartUpList.Add(strt["Command"] + " Method : " + strt["Location"]);
}
var diff = NewStartUpList.Except(StartUpList).ToList();
foreach (var added in diff)
{
MessageBox.Show(added);
}
StartUpList.Clear();
StartUpList.AddRange(NewStartUpList);
}
Code:
StartUpTimer();
In the exemple it just shows a messagebox with the infos of the program added to startup (path and method). You can do what you want with the results (delete registry key, delete binary...).