Solved

registry

Posted on 2000-05-05
11
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month6 days, 7 hours left to enroll

634 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