Solved

registry

Posted on 2000-05-05
11
303 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
Comment Utility
Run "regedit".  Do an Registry -> Export Registry File.
0
 
LVL 9

Expert Comment

by:GivenRandy
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
GivenRandy changed the proposed answer to a comment
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 4

Expert Comment

by:gcs001
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
No problem.
All we're here to do is help ... the points are just a bonus!
Glad you came right dreamvb.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

744 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

8 Experts available now in Live!

Get 1:1 Help Now