Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C# Monitor new startup programs
#1
An interesting function if you want to avoid new programs to be added to windows startup :

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...).
Reply
#2
But then you need to add a program like this to startup, and why would you use a timer? It would have been better to look for windows messages and changes.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Ideas for making some new programs? XDarkCoder 2 1,039 10-01-2012, 10:39 AM
Last Post: XDarkCoder
  Icon Websites? (Looking for Icons for Programs) AceInfinity 14 5,263 09-08-2012, 04:20 PM
Last Post: spesificrelax
  Compilation of My Programs Red X 6 2,351 08-03-2011, 09:05 AM
Last Post: Arron XR
  [Source] Find Installed Programs euverve 3 1,317 05-14-2011, 01:43 PM
Last Post: iCrack
  [Source] Get Startup and Running Process euverve 0 875 05-12-2011, 09:45 AM
Last Post: euverve

Forum Jump:


Users browsing this thread: 1 Guest(s)