简体   繁体   中英

How to get list of all startup processes from Registry using C# on Windows 7 64 bit?

Hi guys I have a strange issue.

I am trying to get list of all startup programs from Registry - LocalMachine,CurrentUser, subkeys Run, RunOnce, RunOnceEx. And after that I can get list of links in Startup folder

For Win64 I found that startup programs are in this key

LocalMachine/Software/Wow6432Node/Microsoft/Windows/CurrentVersion/Run

The problem is in this code, running it I get List of apps which are in different Subkey LocalMachine\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run instead of the described bellow LocalMachine\\Software\\Microsoft\\Windows\\CurrentVersion\\Run

Is that normal?

 Microsoft.Win32.RegistryKey key;
 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", false);

 foreach (string appName in key.GetValueNames()) 
 {
      try
      {
         MessageBox.Show(appName);
      }
      catch (Exception ex) 
      {

      }

 }

I tryed using this WMI solution but it didnt get all startup apps. That's why i decided to get them manually from the Registry.

  1. Is this script correct and why it doesn't do what it is supposed to do?
  2. Is there any other way to get all startup apps and processes?

    Thanks

On a 64-bits windows OS, there are 2 distinct HKLM\\Software hives. One for 64-bits apps (which is HKLM\\Software) and one for 32-bits apps (which is HKLM\\Software\\Wow6432Node when viewed from a 64-bits apps. It is viewed as HKLM\\Software for a 32-bits apps).

If you compile your .Net application as MSIL or x64, you could access the 32-bit software hive by adding Wow6432node to the registry path.

Otherwise, you could also compile as x86 and run in 32-bits.

Hope this help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM