Re-Register DLL/OCX files in the c:\windows\system32 directory

Posted by Blake on 10/22/2010

Every once in a while, a Windows update or other installation occurs that corrupts the registrations of key library files. This could manifest itself in any number of ways. From my personal experience, it's been IE not being able to open links in new windows, the Windows Explorer not being able to open new folders in the same window or errors when applications access certain ActiveX or OLE controls/objects. A lot of times, the fix is to simply re-register the offending DLL/OCX with regsvr32. The problem is knowing which library you need to re-register. These libraries won't necessarily exist in the System32 directory, but often times will (for instance, libraries also exist in C:\Program Files\Internet Explorer (or C:\Program Files (x86)\Internet Explorer). Here's a simple batch script that will re-register all DLL and OCX's in the system directory. It can be adapted to work on any directory or directory tree:

    for %1 in (%windir%system32*.dll) do regsvr32 /s %1
    for %1 in (%windir%system32*.ocx) do regsvr32 /s %1