Tip

Back up the registry with batch files

Back up the registry with batch files
C. Fredrik Krohn

Reader Fred Krohn responds to discussions of RegClean with this tip that solves a problem common to registry tools. You can install the files here on each Windows workstation in your enterprise, and be assured you can get back to a good registry if you have to.


While the MS RegClean tool and others can do a wonderful job of paring down the Windows registry and eliminating dead and obsolete keys, they all have one thing in common: Should the registry become totally bungled from a pass of an automated or manual registry cleanup session, the machine will not boot to the GUI. As most of the standard registry tools need the GUI even to just restore a backup of the registry, this can be fatal.

Using a simple

    Requires Free Membership to View

DOS batch file system to create backups of the registry is an excellent way of avoiding this problem. The backup can be automated into AUTOEXEC.BAT for each startup, or the user can execute manually from a DOS box or from the shutdown to DOS option or Command Prompt startup option.

Create a directory called RegBack with subdirectories called DOS, Crash, and RegEdit in it. Open a blank text file in C: and name it regbak.bat.

With Notepad or other suitable text editor, insert the content:

 @echo off if "%1"=="" goto error c:windowscommandattrib -h -s c:windowssystem.dat c:windowscommandattrib -h -s c:windowsuser.dat copy c:windowssystem.dat c:regbackdos%1.sys copy c:windowsuser.dat c:regbackdos%1.usr c:windowscommandattrib +h +s c:windowssystem.dat c:windowscommandattrib +h +s c:windowsuser.dat goto end :error echo Enter unique file name for backup, date-based suggested, 8 DOS characters echo as parameter for RegBak command. :end

Open another text file and name it RegRsto.bat. Write its lines:

 @echo off if "%1"=="" goto error c:windowscommandattrib -r -h -s c:windowssystem.dat copy c:windowssystem.dat c:regbackcrash%1.sys c:windowscommandattrib -r -h -s c:windowsuser.dat copy c:windowsuser.dat c:regbackcrash%1.usr copy c:regbackdos%1.sys c:windowssystem.dat copy c:regbackdos%1.usr c:windowsuser.dat c:windowscommandattrib +r +h +s c:windowssystem.dat c:windowscommandattrib +r +h +s c:windowsuser.dat goto end :error echo Enter valid backup filename as parameter of RegRsto.bat command. :end

Suggested use: Enter a command like

 regbak 010310

for a 2001 March 10 backup from DOS. The files 010310.sys and 010310.usr will be written to the RegBack DOS subdirectory. Doing this before a major program install or registry cleanup is recommended. Also, if editing the registry, use the RegEdit backup tool and record the backup in the RegEdit subdirectory of RegBack directory (this makes these backups more convenient too).

If the machine crashes hard on a bad registry when rebooted, reboot to the command prompt and DIR the C:RegBackDOS directory. Take the most recent backup there by entering the command

 regrsto 010310

(assuming your last backup was 2001 March 10) and that backup will overwrite the bad Registry -- after the bad registry files are copied to the RegbackCrash subdirectory for analysis.

This is an updated version of a Win3-based IniBak/IniRsto batch command set, using a similar structure to protect the Win.ini and System.ini files. A single user is assumed on the machine. If multiple users are on the system, expand the files copied to cover all users and assign us0, us1, us2, etc. to the different users' DAT file backups. Not all systems will be able to execute the Regbak command from a DOS window; it may be necessary to exit to DOS mode to use this.


Did you like this tip? If so, or if not, why not let us know? Email to sound off, or visit our tips page to rate this, and other, tips.

Related Book

Admin911: Windows 2000 Registry
Author : Kathy Ivens
Publisher : Osborne
ISBN/CODE : 0072129468
Cover Type : Soft Cover
Pages : 354
Published : Oct 2000
Summary:
Keep your network up-and-running with help from Admin911: Windows 2000 Registry. Inside, you?ll find immediate solutions and pointers to quick fixes in the registry for pitfalls and bugs, with coverage of tuning parameters, device configuration, and network settings. Problem-solving, prevention, troubleshooting, performance enhancement, tweaking, and management techniques are presented throughout in a clear, easy-to-follow style. This powerful tool will save you hundreds of hours of network troubleshooting.


 

This was first published in March 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.