Export registry keys?

C

Charlotte E.

Hi,


Is it possible (and, if so, how?) to export a certain key, and all its
values and (if any) subkeys/values, to an .REG-file?

(Just as if you would export from the Registry itself manually)


Thanks in advance,

CE
 
G

GS

I also did some further looking and found the following code samples. I
tested them and it worked just fine 'as is'!

Sub RegeditExport(sKey As String, sFilename As String)
Shell "regedit.exe /s /e " & Chr(34) & sFilename & Chr(34) & " " &
Chr(34) & sKey & Chr(34), vbHide
End Sub

Sub RegeditImport(sFilename As String)
Shell "regedit.exe /s /c " & Chr(34) & sFilename & Chr(34), vbHide
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
C

Charlotte E.

Stupid, stupid, stupid me!

Of cause - should have thought of that - using Shell and the RegEdit isself
as a shortcut :)

Thanks, Garry .-)
 
G

GS

Stupid, stupid, stupid me!
Of cause - should have thought of that - using Shell and the RegEdit
isself as a shortcut :)

Thanks, Garry .-)

Not stupid at all! I originally thought you'd need to enum subkeys
recursively and build a file string of keys, subkeys, and values as you
go. But then I thought there has to be a simpler way, and so I googled.

I wasn't aware of the command line switches regedit.exe exposes and so
was quite pleased to find the sample. It's really 'clean', IMO. I don't
use the Registry at all for my apps because I've configured them to be
fully portable so they can run from a memstick. Thus, I use ini/dat
files to store settings and other data. I do have (and did use
extensively) a similar wrapper (mRegistryAPI.bas) as what I posted the
link for, but I seldom use it anymore.<g> I have updated it, though, to
include these export/import procedures...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top