How to Maintain Current Registry Backups in Windows NT 4.0 and Windows 2000 (318149)



The information in this article applies to:

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional
  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Workstation 4.0

This article was previously published under Q318149

SUMMARY

NOTE: The solution that is described in this article is not supported by Microsoft. Use this method at your own risk.

You may be able to resolve many Windows issues by restoring a backup of the registry that you created before the issue occurred. This article describes how to create a batch file that you can schedule to create periodic, compressed registry backups that you can later use to restore the registry to a known state. Also, if you cannot start the computer, you can restore a registry backup from the Windows 2000 Recovery Console. The batch file creates up to five backups. After five backups are created, the oldest backup is deleted when a new backup is created.

This process uses the Regback.exe tool for backing up the registry, and uses the Makecab.exe tool to compress the backups. Makecab.exe is included with Windows 2000. For Windows NT 4.0, this tool is available as part of the Microsoft Cabinet Software Development Kit (SDK). For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

310618 Microsoft Cabinet Software Development Kit

Regback.exe is a Resource Kit tool. For Windows NT 4.0, use the version that is included in the Microsoft Windows NT 4.0 Resource Kit. For Windows 2000, use the version that is included in the Microsoft Windows 2000 Resource Kit.

MORE INFORMATION

To Back Up the Registry

  1. Create a batch file named Savereg.bat in the %Windir%\Repair folder. Include the following lines in the file:

    set backupdir=%windir%\repair\regback
    set tempdir=%temp%\regback

    if not exist %backupdir% md %backupdir%
    if exist %tempdir% rd /s/q %tempdir%
    md %tempdir%
    regback %tempdir%

    :checknumfiles
    set num=1
    for %%f in (%backupdir%\*.cab) do set /a num+=1
    if %num% LSS 6 goto checkname
    for /f %%i in ('dir %backupdir%\*.cab /a/o-d/b') do set oldest=%%i
    move %backupdir%\%oldest% %backupdir%\%oldest%.old
    goto checknumfiles

    :checkname
    set num=1
    :loop
    if not exist %backupdir%\rb00%num%.cab goto createcab
    set /a num+=1
    goto loop

    :createcab
    set name=rb00%num%.cab
    echo .set inffilename=%backupdir%\setup.inf > %backupdir%\cabdirect.ddf
    echo .set cabinetnametemplate=%name% >> %backupdir%\cabdirect.ddf
    echo .set diskdirectorytemplate=%backupdir% >> %backupdir%\cabdirect.ddf
    echo .set rptfilename=%backupdir%\setup.rpt >> %backupdir%\cabdirect.ddf
    echo .set maxdisksize=cdrom >> %backupdir%\cabdirect.ddf
    for %%f in (%temp%\regback\*.*) do echo %%f >> %backupdir%\cabdirect.ddf

    makecab /f %backupdir%\cabdirect.ddf

    del %backupdir%\cabdirect.ddf
    del %backupdir%\setup.*
    if exist %backupdir%\%oldest%.old del /f/q %backupdir%\*.old
    rd /s/q %tempdir%

  2. Copy the Regback.exe and Makecab.exe files to the %Windir%\System32 directory. For Windows 2000, copy only the Regback.exe file, because the Makecab.exe file is included with Windows 2000.
  3. Schedule daily registry backups. You can run the following command in Windows NT 4.0 and Windows 2000 to schedule the batch file to run every day at midnight:

    at 00:00 /every:m,t,w,th,f,s,su %windir%\repair\savereg.bat

Because the backups are compressed and because only five can be saved on the hard disk, disk space should not be a problem. The size of a registry backup varies, depending on the version of Windows and the number of programs that are installed. For example, a backup from a "clean" installation of Windows NT 4.0 may be less than one megabyte (MB) in size. A backup from Windows 2000 with many programs installed may be over five MB in size.

To Restore the Registry

  1. Insert the Windows 2000 CD-ROM in the CD-ROM drive, and then restart the computer.
  2. Press R to choose Repair.
  3. Press C to choose the Recovery Console.
  4. Select the installation of Windows that you want to restore.
  5. Type the Administrator password, and then press ENTER.
  6. Type cd system32\config, and then press ENTER.
  7. Backup the existing registry files by typing the following commands, pressing ENTER after each command:

    copy default default.bak
    copy sam sam.bak
    copy security security.bak
    copy software software.bak
    copy system system.bak

  8. Type expand %windir%\repair\regback\rb00x.cab /f:* (where %windir% is the folder in which Windows is installed, and rb00x.cab is the registry backup file that you want to restore), and then press ENTER.
  9. When you are prompted to overwrite files, press A to overwrite all files.
  10. Type exit, and then press ENTER to restart the computer.
NOTE: You can restore an individual registry hive by replacing "/f:*" with "/f:filename" where filename is the name of the registry hive to restore. For example:

expand c:\winnt\repair\regback\rb001.cab /f:system


Modification Type:MajorLast Reviewed:5/28/2003
Keywords:kbinfo KB318149