Documente Academic
Documente Profesional
Documente Cultură
Before I begin describing the rebuilding process in detail, let me state that I
know all about REGCLEAN and other Windows utilities that are supposed to
cure registry ills. However, these programs work only if you can boot into
Windows. Even then, Windows is using the very registry we're trying to clean.
To me, this is like working on your car's engine while you're driving. Instead,
we're going to clear things up another way. We're going to do it from DOS.
Warning: The following article involves editing your system registry. Using
the Windows Registry Editor incorrectly can cause serious problems requiring
the reinstallation of your operating system. TechRepublic does not and will
not support problems that arise from editing your registry. Use the Registry
Editor and the following directions at your own risk.
For the sake of simplicity, we'll assume that SYSTEM.DAT, USER.DAT, and
REGEDIT.EXE reside in the C:\WINDOWS directory.
Step one: Remove the ReadOnly and Hidden attributes from SYSTEM.DAT and
USER.DAT
The first step in rebuilding the Windows registry from DOS is to remove the
ReadOnly, Hidden, and System attributes from the SYSTEM.DAT and
USER.DAT files. A batch file that allows you to toggle the attributes off and on
at will (REGATT.BAT) looks like this:
@echo off
goto ENDIT
:INSTRUCT
echo.
:ENDIT
echo.
To use it, enter the command REGATT - or REGATT + to remove or add the
file attributes, respectively.
* @echo off: Prevents the lines that follow from being displayed on the
screen while the commands are being executed. The "@" prevents "echo off"
from displaying.
* if not "%1"=="-" if not "%1"=="+" goto INSTRUCT: This makes the batch
file look for one parameter and limits the parameter choices to either "-" or
"+." If neither is found, the script jumps to the INSTRUCT portion of the batch
file. Note the use of the double "equals" signs (==).
* goto ENDIT: Jumps over the INSTRUCT statement since all went well.
* echo.–: Prints a blank line on the screen. Note that there is no space
between "echo" and "."
* echo.: Prints a blank line on the screen before returning to the prompt.
@echo off
goto ENDIT
:INSTRUCT
echo.
:ENDIT
echo.
@echo off
echo.
user.dat /e c:\windows\newreg.reg
echo Rebuilding the Windows registry. Do not interrupt!
user.dat /c c:\windows\newreg.reg
echo.
del c:\windows\newreg.reg
echo.
* echo.: The progress counter that is displayed by REGEDIT does not have
a carriage return. This statement forces one at the completion of the "create"
process.
Step four involves returning the registry to its previous state in the event a
failed rebuild leaves you without working SYSTEM.DAT and USER.DAT files.
We'll call this batch file REGRET.BAT. Remember the extension you used
when creating your backups? You'll need it here:
@echo off
attrib -r -h -s c:\windows\system.dat
attrib -r -h -s c:\windows\user.dat
del c:\windows\system.dat
del c:\windows\user.dat
goto ENDIT
:NOFILE
echo.
:INSTRUCT
echo.
echo You must give a valid backup file extension, as in "%0 ext"
:ENDIT
echo.
REGRET.BAT runs by entering “regret ext” at the prompt, where “ext” is the
extension you used when creating your backups. If the ext files aren’t found,
REGRET tells you. All of the REGRET commands are similar to ones we've
used in the previous batch files. Note that after we delete the failed
SYSTEM.DAT and USER.DAT files, we copy the backups to the DATs as
opposed to renaming the backups. I never feel comfortable deleting critical
backup files until I'm absolutely sure they won't be needed again. Delete
them manually when you are comfortable.
Now that you have your batch files, go ahead and try them on a sick system.
Boot the PC to a true DOS "Safe mode command prompt only" and run the
files from a floppy. If you make the floppy bootable, be sure that you have an
AUTOEXEC.BAT that contains a path statement pointing to
C:\WINDOWS;C:\WINDOWS\COMMAND. A successful rebuilding of the registry
will solve many of your "mysterious" Windows problems, including many
Windows protection errors.
What do you think of the method for rebuilding a registry described here? Do
you know of a better way to solve this problem? We want to know.