none
Show Startup Programs

    Question

  • How can i show the startup programs from: HKLM, HKCU, and the startup folder ?

    i made this, but it's totally wrong, neve tried switch before !

            private RegistryKey GlobalReg;
            private void Read()
            {
     
                switch (startup)
                {
                    case "HKEY_LOCAL_MACHINE":
                        GlobalReg = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                        break;
     
                    case "HKEY_CURRENT_USER":
                        GlobalReg = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                        break;
                }
            
                foreach (string programas in GlobalReg.GetValueNames())
                {
                    ListViewItem item1 = listView1.Items.Add(programas);
                    item1.SubItems.Add(GlobalReg.Name.ToString().Replace("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion", "HKLM"));
                    item1.SubItems.Add(GlobalReg.GetValue(programas).ToString());
                }
     
                GlobalReg.Close();
     
            }
        }
    Monday, August 28, 2006 12:53 AM

Answers

  • Hi!

    I think my information could help you...

    We are going to use Windows Management Instrumentation (WMI) for this type of task.

    First you need to do the following steps:

    1.    Start Visual Studio 2005/2008.

     

    2.    Creat a new C# application

     

    3.    Add a listview and an imagelist with a selected icon with the  size 16-bit from the desktop or custom dir.  

     

    4.    Add the following references:  

     

     

    using System.Management;  
    using System.Management.Instrumentation;   

    Code-snippet1: Add the above code to get access to "ManagementObject, ManagementObjectSearch etc.

    5.   

    Double-click on the form and add the following code:

     

     ManagementClass mangnmt = new ManagementClass("Win32_StartupCommand");  
                ManagementObjectCollection mcol = mangnmt.GetInstances();  
                foreach (ManagementObject strt in mcol)  
                {  
                   listView1.Items.Add(strt["Name"].ToString(), 0);  
                } 

    Code-snippet2: The following code will list up all startup programs on your computer.  

    6.   
    Build and test run the application to see if it works.

     


    My application looked like this: 
    http://phjh4q.blu.livefilestore.com/y1pHO6A-qiSIH9KZ6cgt91Vnn60wqCmxzhBTm5nPn3YbTNrlSOfTNq5DqmUyyKXhYy-E2OEMvW6rV1rJIMHFE79gdsbRVnRVZbq/1.jpg

    Find out more information about WMI:
    http://msdn.microsoft.com/en-us/library/aa394582(VS.85).aspx
    http://www.microsoft.com/technet/scriptcenter/resources/wmifaq.mspx

    You can visit my website to: http://www.coder24.com


    Have a great day...

    Regards,
    Fisnik

     

     

     


    Coder24.com
    Saturday, August 30, 2008 9:47 AM
  • to get things like that, it is different than the startup applications, as these are background applications I believe. To do this, try this:

     



    RegistryKey theKey = Registry.LocalMachine.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
    string[] theValueNamesOfKey = theKey.GetValueNames();
    foreach(string currentValueName in theValueNamesOfKey)
    {
       MessageBox.Show(currentValueName);
    }

     

     

    this will get a list of the background startup processes in that registry key

    does this help?

    Monday, August 28, 2006 5:14 PM

All replies

  • why don't you just access the startup folder and get your items from there instead of accessing the registry, which would kind of be bad practice but mainly for security reasons (unauthorizedaccess/securityException)

     

    string[] theStartUpMenuItems = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu));

     

    Monday, August 28, 2006 2:33 AM
  • yeah but i'd like to show all programs that will start with the pc !
    using this i'll get only the ones which are in the startup folder. In my computer for example just showed desktop.ini !
    Monday, August 28, 2006 4:40 PM
  • if you are talking about background services that are loaded with the startup system, then thats different. The method I described and also as you had said, it shows a list of programs which will startup when Windows starts up - the applications to launch at startup.

     

    Monday, August 28, 2006 4:46 PM
  • I'm talking about registry entrys !
    NOD32, Nero, Spy Sweeper, nVidia, they are at the registry and the startup ! How can i show then + the startup folder?
    Monday, August 28, 2006 4:51 PM
  • But, programs like anti-virus, anti-spyware, nVidia, they run from the registry, i'd like to show this programs + programs from the startup folder.
    Monday, August 28, 2006 4:53 PM
  • to get things like that, it is different than the startup applications, as these are background applications I believe. To do this, try this:

     



    RegistryKey theKey = Registry.LocalMachine.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
    string[] theValueNamesOfKey = theKey.GetValueNames();
    foreach(string currentValueName in theValueNamesOfKey)
    {
       MessageBox.Show(currentValueName);
    }

     

     

    this will get a list of the background startup processes in that registry key

    does this help?

    Monday, August 28, 2006 5:14 PM
  • Yeah, i'm using like this:

                RegistryKey rkey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
     
                foreach (string programas in rkey.GetValueNames())
                {
                    ListViewItem item1 = listView1.Items.Add(programas);
                    item1.SubItems.Add(rkey.Name.ToString().Replace("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion", "HKLM"));
                    item1.SubItems.Add(rkey.GetValue(programas).ToString());
                }
     
                rkey.Close();

    But if i want to show what i have in Registry.CurrentUser and startup folder too (list all they in a treeview)? Thats my problem :(
    Monday, August 28, 2006 5:29 PM
  • Hi!

    I think my information could help you...

    We are going to use Windows Management Instrumentation (WMI) for this type of task.

    First you need to do the following steps:

    1.    Start Visual Studio 2005/2008.

     

    2.    Creat a new C# application

     

    3.    Add a listview and an imagelist with a selected icon with the  size 16-bit from the desktop or custom dir.  

     

    4.    Add the following references:  

     

     

    using System.Management;  
    using System.Management.Instrumentation;   

    Code-snippet1: Add the above code to get access to "ManagementObject, ManagementObjectSearch etc.

    5.   

    Double-click on the form and add the following code:

     

     ManagementClass mangnmt = new ManagementClass("Win32_StartupCommand");  
                ManagementObjectCollection mcol = mangnmt.GetInstances();  
                foreach (ManagementObject strt in mcol)  
                {  
                   listView1.Items.Add(strt["Name"].ToString(), 0);  
                } 

    Code-snippet2: The following code will list up all startup programs on your computer.  

    6.   
    Build and test run the application to see if it works.

     


    My application looked like this: 
    http://phjh4q.blu.livefilestore.com/y1pHO6A-qiSIH9KZ6cgt91Vnn60wqCmxzhBTm5nPn3YbTNrlSOfTNq5DqmUyyKXhYy-E2OEMvW6rV1rJIMHFE79gdsbRVnRVZbq/1.jpg

    Find out more information about WMI:
    http://msdn.microsoft.com/en-us/library/aa394582(VS.85).aspx
    http://www.microsoft.com/technet/scriptcenter/resources/wmifaq.mspx

    You can visit my website to: http://www.coder24.com


    Have a great day...

    Regards,
    Fisnik

     

     

     


    Coder24.com
    Saturday, August 30, 2008 9:47 AM