Restore Config Files – restcfg.bat
Note that this batch file MUST run from Command Prompt Only. That is, press F8 before Windows starts to boot and choose Command Prompt Only from the boot menu. Also very important, if your Windows directory is anything other than C:\Windows you MUST edit this file accordingly. Change the destination of each command that copies a file to the Windows directory. Be careful not to affect the position of command line switches. I cannot use a variable to represent the Windows directory in this case. If you accidentally double-click this file from within Windows, I have given you the opportunity to abort. Press Ctrl+C (press and hold the Ctrl key while pressing the letter C) If you followed my explanation of cfgbak.bat then you should understand the commands in this batch file.
@echo This batch file must run from COMMAND PROMPT ONLY
@echo It will replace your registry & configuration files from backup
@echo Press any key to continue or ctrl+c to terminate process
@pause > null
attrib -r -h -s c:\windows\system.dat
attrib -r -h -s c:\windows\user.dat
attrib -r -h -s c:\msdos.sys
copy /b c:\cfgbak\system.dat c:\windows /b /v /y
copy /b c:\cfgbak\user.dat c:\windows /b /v /y
copy c:\cfgbak\msdos.sys c:\ /v /y
attrib +r +h c:\windows\system.dat
attrib +r +h c:\windows\user.dat
attrib +r +h +s c:\msdos.sys
copy c:\cfgbak\system.ini c:\windows /v /y
copy c:\cfgbak\win.ini c:\windows /v /y
if EXIST c:\cfgbak\autoexec.bat copy c:\cfgbak\autoexec.bat c:\ /v /y
if EXIST c:\cfgbak\config.sys copy c:\cfgbak\config.sys c:\ /v /y
How to Use this Batch File
This batch file should be copied to the root directory of drive C: so that you can simply type restcfg from the C:\> prompt. It MUST be executed from Command Prompt Only because the registry cannot be overwritten from within Windows. Either copy the text from the textbox to Notepad and save it as restcfg.bat in the root directory (edit it first if necessary), or download the zip file. If you download the zip file, you will have to rename restcfg.txt to restcfg.bat after editing.
Warning! Make sure that your backups are current. If you restore an old backup it could be fatal if you’ve made major changes to the operating system or hardware since the backups were created. For example, if you’ve installed Internet Explorer 5 and restore your registry from a backup predating that, expect that your computer won’t boot properly. An example of correct usage would be to make current backups immediately before installing new software, then if it doesn’t go as planned UNINSTALL the software and if your system isn’t right you can restore the configuration files.
Get cfgbak.zip (cfgbak.bat and restcfg.txt)
If you are running Windows 98
The batch files I made will work equally as well as in Windows 95, however there is a much easier and automated method provided with Windows 98. Once a day (when your computer boots) by default, a backup of the two registry files as well as system.ini and win.ini is created in cabinet files (compressed archives) in the hidden directory \windows\sysbckup. By default, 5 backups are kept. If you want to have a look, make sure Windows Explorer is set to show all files and extensions and go to that directory and look for files named “rb00x.cab” where the x is a number. The ScanregW (Win32 version) runs at startup and checks the registry for corruption, compacts it when it detects wasted space, and makes these backups once a day. If at any time you want to make a current backup, simply go to Start, click Run and type scanregw and hit Enter. Click Yes to answer the question “Your registry has already been backed up today, would you like to back it up again?”
Use Scanreg to Restore the Registry and .ini Files
There is a real mode command line utility called scanreg.exe that is used from the Command Prompt Only boot option that can be used to “fix” or “restore” a damaged registry (as well as make a backup if desired).
To see the available switches, type SCANREG /?
To attempt to repair a damaged registry, type SCANREG /FIX
To restore a damaged registry and ini files (that is, replace them from the backup), type the following command. This will allow you to choose the backup you want to restore from.
Here is an undocumented switch for scanreg that forces it to compact the registry by eliminating wasted space:
Change Default Behavior of Scanreg
You can make Scanreg include additional files in the backups, or change the location of the backup cab files, or make it keep more than five backups by editing the Scanreg.ini file in the Windows directory. Open it with notepad and you will see lines commented out with semi-colons that explain how to make these changes. E-mail me for specific questions you may have.
Additionally – Use Regedit to back up Registry
The registry editor, Regedit.exe, also provides a method for backing up and fixing or restoring the registry. Easiest way to open Regedit in the Windows directory is to go to Start, click Run and type regedit and hit Enter. In regedit, go to the Registry menu (where “File” normally is) and choose Export Registry File. Make sure that the bullet All is checked under Export Range. Save the .reg file (eg. RegBak.reg) in the root of drive C: for easy access. There are two ways that you can use this backup. At any time in Windows you can double click the .reg file to “merge” it with your registry. This may correct a problem, however it cannot remove keys, only add keys or change values of existing keys. If your registry backup is not current it could also cause problems, or perhaps add erroneous keys if you’ve since uninstalled software. To use this backup to restore a corrupt registry, boot to Command Prompt Only and type the following command.
REGEDIT /C REGBAK.REG
The /C switch tells it to completely rebuild the registry from the text based .reg file. This is also used to compact the registry. (eliminate wasted space)
– Grogan –