Solved

registry

Posted on 2000-05-05
11
311 Views
Last Modified: 2010-05-02
Hi Experts

is there any way of extracting all the registry keys and value to a file
 What I want to do is try and make a small program to back up my registry incase my computer ever goes down.
can some please point my to the right place or maybe some one has some code

0
Comment
Question by:dreamvb
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2783211
Run "regedit".  Do an Registry -> Export Registry File.
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2783214
The resulting file will look something like:

REGEDIT4

[HKEY_LOCAL_MACHINE]
"FullLogging"="No"
"EnablePowerManagement"=hex:30,30,30,30
"IE State"=dword:00000000

[HKEY_LOCAL_MACHINE\Software]

[HKEY_LOCAL_MACHINE\Software\Microsoft]

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows]

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
"InstallType"=hex:03,00
"SetupFlags"=hex:08,05,00,00
"DevicePath"="C:\\WINDOWS\\INF"
"ProductType"="101"
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2783220
By the way, you can use RegEdit to import your previously saved file.

You can run RegEdit by clicking Start -> Run -> regedit
0
 
LVL 4

Author Comment

by:dreamvb
ID: 2783230
I now that you can Export Registry File with reg edit but I want to Export Registry in Visual basic with code.
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2783253
GivenRandy changed the proposed answer to a comment
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:gcs001
ID: 2783455
All you basically need to do is copy the files System.Dat and User.Dat to another location - these are your registry files.
Everytime Windows loads successfully it creates a copy of the System.Dat and User.Dat files to System.Da0 and User.Da0, so it creates a copy all on it's own.
Remember that these files are System/ Hidden/Read Only files, so you will have to set the attributes to Non System/Unhidden to copy the files to another location and then set the attributes back.

Here is a DOS batch file that you could use to do so ...

attrib -h -s user.dat
copy user.dat userdat.bkp
attrib +h +s user.dat

attrib -h -s system.dat
copy system.dat systemdat.bkp
attrib +h +s system.dat


To recover your registry you just have to the copy these backed up files to the Windows directory (or Winnt) in the correct file names, i.e. User.dat and System.Dat

Hope this helps.

Regards,
Grant.
0
 
LVL 3

Accepted Solution

by:
fibdev earned 20 total points
ID: 2783911
vb example of gcs001's example, you should make sure everything is setup correctly for this and the exe in this example should be in the system directory or the pathnames should be changed to look for the files in the system directory.  I would recomend backing up your registry using rededit befor you try this example.  If anyone sees any typos or anything I left out, please shout out asap:

Private Sub cmdRegBackup_Click()
Dim SourceFile, DestinationFile
SourceFile = "User.dat"  ' Define source file name.
SetAttr SourceFile, vbNormal
DestinationFile = "User.bkp"    ' Define target file name.
FileCopy SourceFile, DestinationFile    ' Copy source to target.
SetAttr SourceFile, vbHidden + vbReadOnly
SetAttr DestinationFile, vbHidden + vbReadOnly ' protect the backup files

SourceFile = "system.dat"
DestinationFile = "system.bkp"
FileCopy SourceFile, DestinationFile
SetAttr SourceFile, vbHidden + vbReadOnly
SetAttr DestinationFile, vbHidden + vbReadOnly ' protect the backup files

Label1.Caption = "Registry backup successful"
End Sub

Private Sub cmdRestoreReg_Click()
Dim SourceFile, DestinationFile
SetAttr SourceFile, vbNormal
SourceFile = "User.bkp"  ' Define source file name.
DestinationFile = "User.dat"    ' Define target file name.
FileCopy SourceFile, DestinationFile    ' Copy source to target.
SetAttr SourceFile, vbHidden + vbReadOnly
SetAttr DestinationFile, vbHidden + vbReadOnly


SourceFile = "system.bkp"
DestinationFile = "system.dat"
FileCopy SourceFile, DestinationFile
SetAttr SourceFile, vbHidden + vbReadOnly
SetAttr DestinationFile, vbHidden + vbReadOnly

Label1.Caption = "Registry restore successful"
End Sub

' this example requires two command buttons and a label
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2783942
I wouldn't advise running the Registry restore from within Windows, i.e. rather boot into DOS (not a DOS window!!!) and do the restore from there, either with a DOS batch file or manually copy the files.
0
 
LVL 3

Expert Comment

by:fibdev
ID: 2783944
Hey gcs,

What if you did the file coping as demonstrated in my vbexample, then forced the system to reboot?  I agree, you're probably right and it should be advised to do all this in native dos, but the question was asking for a vb solution.

:)

On second thought, Use gcs's example and create backup and restore batch files to be run under dos.
0
 
LVL 3

Expert Comment

by:fibdev
ID: 2784549
Uh ...

Thanks for the points.  I know I offered a solution, but to be honest ...  gcs001 is right about making changes like this in native dos.  *shrug*
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2787143
No problem.
All we're here to do is help ... the points are just a bonus!
Glad you came right dreamvb.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now