×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Editing the Registry

Trimming unused things from the Windows Registry by jnicks
Posted: 1 Sep 02 (Edited 6 Apr 03)

Misrosoft wants you to think of their OS's are sleek, like Porsches, but if you look at the internals in the registry it is more like a tinker's cart from two centuries ago, piled with junk.  

I know that many are afraid of the Registry, but it is not too bad if you take backups and are methodical, it is after all, just a big pile of junk.

I recently finished developing some tools and shrinking my registry from 3.7 M to 2.3 M, removing 2,400 keys that were not being used. Performance increased, tasks start faster, boot and shutdown are faster, and the system is more secure.

The system I was working on is like many office systems, it needs no sound, no moving images, no joystick.  Eliminating support for these freed up a lot.  Even the home user who needs articulated images and sound does not need, in all likelihood:


  • the international dialing for Tuvalo, and two hundred other countries
  • the time zone of Smolensk, and four hundred other cities
  • Configuration for Mplayer (not Mplayer2, Mplayer!)
  • and a few hundred other things


In terms of security, evn though the system was pretty clean I found that Netscape had made Mplayer a 'trusted app' without asking me.  Do I trust Mplayer?  No.  Netscape no longer has any trusted apps.  

It is well known that the registry accumulates things, that once it has them, like a pack rat, it is reluctant to let them go.  For example if you install a package and the uninstall is fractious, then you install it again, the Registry keeps '.1' values.  This system had almost a hundred HomePage.1
items, and HomePage has not been installed since last century. You may find a lot of '.1' and '.2' ... values.

                   How To

Before you start, Backup.

Do not use Regedit in Windows except as a viewer.   

By the way, the Windows RegEdit Export does NOT backup the entire registry by default, just the Local_Machine.  This may well be the cause of many people's grief, as they backed up, did something wrong in another area of the registry and scragged the system without any ability to recover.

You could click the top level items one by one and export them, but a lot easier and more consistent is running a BAT file:

Re-Boot to DOS.  I know, we just lost the NT/2k readers, but this is the 98 forum.  
Here is the registry usage info.


REGEDIT [/L:system] [/R:user] filename1
REGEDIT [/L:system] [/R:user] /C filename2
REGEDIT [/L:system] [/R:user] /E filename3 [regpath1]
REGEDIT [/L:system] [/R:user] /D regpath2

  /L:system       Specifies the location of the SYSTEM.DAT file.
  /R:user         Specifies the location of the USER.DAT file.
  filename1       Specifies the file(s) to import into the registry.
  /C filename2    Specifies the file to create the registry from.
  /E filename3    Specifies the file to export the registry to.
  regpath1        Specifies the starting registry key to export from.
                  (Defaults to exporting the entire registry).
  /D regpath2     Specifies the registry key to delete.


If we are in DOS we can safely backup much more of the regitry with a procedure.


regedit /e root.reg HKEY_CLASSES_ROOT
regedit /e cu.reg   HKEY_CURRENT_USER
regedit /e lm.reg   HKEY_LOCAL_MACHINE
regedit /e users.reg   HKEY_USERS
regedit /e curcfg.reg  HKEY_CURRENT_CONFIG
echo. | appendfl *.reg >regnow.reg


That last statement puts all the results in one file, RegNow.Reg.  If you don't have NULL and Appendfl, you can use COPY commands to add the files together into one big one, RegNow.Reg.

         Restoring The Registry

You will delete something needed.  Just accept that.  To restore the registry back to the way it was:


regedit /i root.reg
regedit /i cu.reg
regedit /i lm.reg
regedit /i users.reg
regedit /i curcfg.reg


or RegEdit /i RegNow.Reg
(some systems will not backup   Current_config, go figger).

The River modules are available along with their source at http://www.roninsoftwaregroup.com/r2app.htm including appendfl, kepwithi, prepline and delbracks.


At this point you should have a 4 to 8 meg file named RegNow.Reg.  We need to


  1. Look through the registry finding unwanted values
  2. Delete them.


          Finding unwanted values.

To look through the registry  to find unwanted values, root through RegNow.Reg and keep only keys, and then only the ones we are interested in.

You could do it in WordPad, but more effective is another little procedure:\.

The following finds all the joystick keys


RegLook joystick


RegLook

type regnow.reg| kepwithi all ]| kepwithi any %1 %2 %3 %4 %5 %6 %7 %8 %9>reg.out
Edit reg.out


The first KepWithI whittles it down to only Keys and the second selects the items ytou are interested in.

You will then create a file of just keys,  Reg.Out.  Edit it to visually confirm that you wish to remove these keys.

It is trivial to transform reg.out into a Batch file that deletes the keys.  The key ingredients here are PrepLine which converts
  [hkey\...]
to
  RegEdit /d [hkey\...]

and delBrack  which drops the brackets converting the line into a valid RegEdit delete command.


ifl reg.out | prepline "regedit /d " $$lin| delbrack >regdel.bat
copy  alldeletes + regdel.bat alldeletes.bak
copy  alldeletes.bak alldeletes


This creates RegDel.BAT which is ready to delete the keys.  Look at it, give it a visual check before you run RegDel.Bat.

Run RegDel.Bat, and your registry keys are removed.

Reboot and make sure things still run.  You took a backup, right?

The two ALLDelete files are historical copies backups of your delete commands.  

If you have gone too far, you restore.  Now you have the old registry with no deletes.

Remove the last lines from AllDeletes, save it as a BAT file, and re-apply the deletes.



       Compressing the Registry

While in DOS run ScanReg /Fix /Opt.  This recreates your registry throwing out unused space.  Remember that the Registry is a data base, and data bases do not eliminate unused space until 'compress' is run. ScanReg is the registry's compress.


scanreg /fix /opt
del c:\windows\*.bad
dir c:\user.dat /s/ah >snap
dir c:\system.dat /s/ah >>snap
type snap


                 Notes



  1. DOS.  Probably the very best reason for working in DOS is not just that procedures are easier, if you do all your tasks in DOS in, say, C:\REGTRIM, then if you really go to far and Windows refuses to work you can boot in DOS and you know exactly where the materials are for the complete restore.

  2. A system that is meant to run office work can lose all the multi-media stuff, and if you remove it from the regitry the system will be almost as fast as Win 3.11 was. (joke, sort of.  Win 3.11 could launch Word a lot faster than 9x/nt/2k/me can, and on a computer 10 times slower).

  3. If you use QuickTime or Real Audio, you can lose Mplayer and Mplayer 2

  4. The MS Paint, Draw and most of their ActiveX objects for multimedia are pitiful, and if you can lose IE you can also lose an immense amount of bad code pointers in the Registry.  Get Opera or Mozilla.

  5. RegClean is useful.  After you have removed some keys, RegCLean will look around for CLASSIDS, those strings of random digits, and remove the ones that are no longer used.  This is sort of right, smile.   Run RegClean and look at the keys removed and you will see what I mean.

  6. At the top we said 'methodical'.  Double check to see that you can undo any particular step.  If you are this methodical, you can edit the registry with confidence.

  7. Expect to fail at first.  Deleting items from the registry is addictive.  Be prepared to backtrack, and put it way and start again some other day.

    We still have the backup from May 2001, when we started poking into how to trim up the registry.



When you are all done, your system will be faster.

On the test system the time between when Windows raises the background and
when it puts up the password screen dropped to 2.8 seconds from 5.6
seconds.

A lot of other things launch faster, too.

Almost as fast as Win3.11


Back to Microsoft: Windows FAQ Index
Back to Microsoft: Windows Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close