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
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
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
(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.
Windows 2000 Registry
Author : Kathy Ivens
Publisher : Osborne
ISBN/CODE : 0072129468
Cover Type : Soft Cover
Pages : 354
Published : Oct 2000
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