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?
73 Answers
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 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.regand 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:
2You 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-LocationThis 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.txtNote that HKCR is actually a combination of entries from places in HKLM and HKCU, so exporting it would be duplicitous.