List Every Single Registry Key in Windows

8,334

Solution 1

Thanks to a comment by IT Solutions, I found the answer to this. Below is the command line code:

reg.exe export HKEY_LOCAL_MACHINE C:\path\machine_registry.txt
reg.exe export HKEY_CLASSES_ROOT C:\path\local_registry.txt
reg.exe export HKEY_CURRENT_USER C:\path\current_registry.txt
reg.exe export HKEY_USERS C:\path\users_registry.txt
reg.exe export HKEY_CURRENT_CONFIG C:\path\config_registry.txt

Solution 2

You can use PowerShell!

Function ListSubkeys($rootKey) {
    Get-ChildItem -LiteralPath $rootKey -ErrorAction SilentlyContinue | % {
        $_.Name # Output the item's name
        ListSubkeys $_.Name # Recurse into its subkeys
    }
}
Push-Location $args[0]
ListSubkeys $args[0]
Pop-Location

This script defines a recursive function ListSubkeys and then calls it. To use it, save that code as a .ps1 file. After following the instructions in the Enabling Scripts section of the PowerShell tag wiki, you can run it from a PowerShell prompt like this, specifying the file name and the starting key in PowerShell path format (the trailing \ is important):

.\regkeys.ps1 'HKLM:\'

To send the output to a file, use the > redirection operator, like so:

.\regkeys.ps1 'HKCU:\' > C:\Users\me\Documents\allmyHKCUkeys.txt

Note that HKCR is actually a combination of entries from places in HKLM and HKCU, so exporting it would be duplicitous.

Solution 3

from command line:

reg.exe export HKLM\hardware hklm-hw.reg
reg.exe export HKLM\sam hklm-sam.reg
reg.exe export HKLM\security hklm-sec.reg
reg.exe export HKLM\software hklm-sw.reg
reg.exe export HKLM\system hklm-sys.reg

'' the same for HKCU branch
reg.exe export HKCU\folders hkcu-folders.reg

and so on... then parse what you want or use compare option to get difference

You can also use WinMerge to compare and get diff between registry snapshots

To save the whole registry in text format just run regedit.exe and export everything from the root of registry.

If you want to do that programmatically there is already answer to this question: https://stackoverflow.com/q/6825555

Share:
8,334

Related videos on Youtube

B00TK1D
Author by

B00TK1D

"Start Early, Work Hard, Never Quit"

Updated on September 18, 2022

Comments

  • B00TK1D
    B00TK1D almost 2 years

    I am trying to either find or generate a list of all the registry keys that exist in several versions of Windows. I have searched extensively online, without finding any such list or a command to recursively generate such a list. Does anyone know how to get a list like this?

    • B00TK1D
      B00TK1D over 7 years
      @Ramhound - Could you please expound on that, in the form of an answer? If you could post the specific commands, I would much appreciate it. Thanks!
    • Tim Haintz
      Tim Haintz over 7 years
      blogs.technet.microsoft.com/heyscriptingguy/2012/05/11/… you would have to enumerate using a loop as a couple of of other people have mentioned. The link has examples of how to do it using PowerShell.
    • DanHolli
      DanHolli over 7 years
      couldn't you just copy the hive files?
    • Alex
      Alex over 7 years
      @Kernel Stearns Isn't it what option compare do in reg.exe ?
    • Vomit IT - Chunky Mess Style
      Vomit IT - Chunky Mess Style over 7 years
      If you want a text document with all the registry paths, keys, values, and so on with a text file you can open to look at the detail, then just using the standard regedit export function to a .REG file (which is a text file) and then open it with a text editor and there you go. You can rename the extension from .reg to .txt if you wish as well.
    • B00TK1D
      B00TK1D over 7 years
      @ITSolutions - Thanks for the comment, that was what I was looking for. I will post it as an answer to my own question now.
    • Ramhound
      Ramhound over 7 years
      "but I want a script that will go through recursively and spit out a text document that has the full path to every registry key automatically." - You should rephrase your question, so I can retract my close vote, and reverse my vote. We are not a script writting service, but this doesn't require a script, so you don't need to (nor should you) ask for one.
  • B00TK1D
    B00TK1D over 7 years
    The stack overflow link is for a question very similar to mine, but nobody ever tells the guy why his code doesn't work. Therefore, I have a link to a script that does what I am trying to do, except that it doesn't work.
  • Alex
    Alex over 7 years
    There is official API to your subject msdn.microsoft.com/en-us/library/windows/desktop/…