Regedit: Find and export keys from command prompt
Asked Answered
A

3

8

I'm wondering is there any option via command line to search for a string and export all found keys in Windows registry?

Avra answered 14/3, 2013 at 12:19 Comment(0)
D
6

Powershell has registry iteration capabilities. Start here: http://technet.microsoft.com/en-us/library/ee176841.aspx

Deimos answered 14/3, 2013 at 12:47 Comment(1)
Thanks @durilka. I was able to solve this problem using powershell command Get-ChildItem -recurse Registry::HKEY_CLASSES_ROOT\CLSID | ForEach-Object {Get-ItemProperty $_.pspath} | where {$_ -match "string to find"}Avra
S
12

Ex:: If you want to check whether "HKLM\software\etc" key exists.

reg.exe query "HKLM\Software\etc" will return all the subkeys and values in command prompt if found or an error if not found.

ALso, you can directly do

reg.exe export "HKLM\software\etc" "C:\etc.reg"

This will export the registry key and subkeys if found otherwise error if not found.

Szechwan answered 14/3, 2013 at 13:4 Comment(6)
How does this "search for a string" as was asked in the question?Bogy
@DaveInCaz - And what string are you exactly talking about?Szechwan
the question says "I'm wondering is there any option via command line to search for a string"Bogy
@DaveInCaz - I am not able to understand your doubt. By string, the OP is referencing to keys and subkeys, not the data or value of the keys, if that is your doubt. For your reference:: search for a string and export all found keys Szechwan
granted he did not specify an example, unfortunately, but I understood "search" to mean something more powerful. for instance, to discover all keys containing a specific string. Not necessarily an exact key name or subset of known keys.Bogy
@DaveInCaz - Yeah, that is one possibility and I think, that's why this answer is not the accepted one. I answered as I understood the question.Szechwan
D
6

Powershell has registry iteration capabilities. Start here: http://technet.microsoft.com/en-us/library/ee176841.aspx

Deimos answered 14/3, 2013 at 12:47 Comment(1)
Thanks @durilka. I was able to solve this problem using powershell command Get-ChildItem -recurse Registry::HKEY_CLASSES_ROOT\CLSID | ForEach-Object {Get-ItemProperty $_.pspath} | where {$_ -match "string to find"}Avra
V
2

export key (with all sub-keys), from CMD (or RUN) i.e.:

regedit /e c:\output.reg "HKEY_LOCAL_MACHINE\System\YourLocation"

p.s. you should run this in CMD with ADMIN PRIVILEGES. for that, right click on START>Run CMD (as Admin)

Vesperal answered 31/7, 2014 at 7:31 Comment(1)
It doesn't work with Wow64. It always export keys from Wow6432Node.Sext

© 2022 - 2025 — McMap. All rights reserved.