How and Why to Use the regsvr32.exe Utility [Examples]


The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

The regsvr32.exe utility is a commonly used, yet little understood and often overused tool that helps to remedy issues with Windows Registry Entries (.reg) files. The regsvr32.exe is not a file itself but rather an executable application that can be run by double-clicking on the icon or by typing in “command prompt” into your Start menu search field followed by “run”. If you are having problems with .reg files this article will provide some useful information about what might have caused these errors and how to fix them using the regsvr32.exe utility..

The “regsvr32 command line options” is a tool that can be used to register files into the Windows Registry. This tool can also be used as an example of how and why to use it.

How and Why to Use the regsvr32.exe Utility [Examples]

If you’re a Windows user, you’ve undoubtedly had to use the regsvr32.exe application to “register a DLL” at some point. If such was the case, you were presumably unaware of what was going on under your bed. Object Linking and Embedding (OLE) controls are utilized by many Windows programs, and this cryptic software is used to handle them.

But what is an OLE control precisely, and why would you want to register one? In this article, you’ll learn how to use the regsvr32.exe program to install, remove, register, and unregister an OLE control.


To execute the regsvr32.exe tool, make sure you have the following requirements:

  • You simply need a Windows PC with an administrator account since the regsvr32.exe function is built-in to most versions of Windows.
  • To use the PowerShell script provided in this article, you’ll need PowerShell 7.

What are OLE Controls and how can I use them?

Before you learn how to utilize the regsvr32.exe program, you need have a basic grasp of OLE controls, which this tool maintains.

OLE controls are a Windows-only technology that allows you to embed and connect to documents and other objects. Over time, OLE technology has developed and additional components have been created on top of it.

Component Object Model (COM), Distributed Component Object Model (DCOM), and ActiveX controls are all terms you’ve probably heard of. Each of these technologies is based on or extends the OLE technology, which offers a common interface for functions written in a variety of languages.

ActiveX is deprecated in Windows 10, however it is still accessible in Internet Explorer, but not in Microsoft Edge.

OLE Controls Registration

Now that you know what the regsvr32.exe program does, you may use one of many command variations to register an OLE control. Choose one command variation from the list below, or try them all.

OLE controls may be registered using PowerShell or a Windows command prompt. To guarantee that the control is correctly registered, make sure you’re running your command line as an administrator in either case.

Using a GUI to Display a Result

At its most basic level, Adding a DLL to the system using regsvr32 entails providing the tool with the DLL path. By default, regsvr32 will show a success message (or failure). To register a DLL, provide the DLL’s name or complete path as shown below.

The registry classes for the target OLE control will be created in the HKEY CLASSES ROOTCLSID key for x64 instances and HKEY CLASSES ROOTWOW6432NodeCLSID for x86 instances when you run the command below.

If DllRegisterServer was successful, you’ll receive a GUI result stating such.

Adding a DLL to the systemAdding a DLL to the system

Regsvr32.exe will use the system search path when registering an OLE control. As a result, if you need to register a file that isn’t in that path, it’s advisable to provide it an absolute path.

Silently registering an OLE Control

It’s not always necessary to have a GUI prompt show while executing commands. So, let’s look at how you may avoid getting a GUI prompt when you register an OLE control.

To register the OLE control without prompts, execute regsvr32 followed by the DLL name (msxml3.dll) and the /s switch. The only drawback of this command is that any error messages will be suppressed as well.

There is an undocumented option, /e, that simply suppresses the GUI success message while displaying the GUI error message—smart!

Adding a DLL to the system silentlyAdding a DLL to the system silently

Specifying an Install Action and Registering an OLE Control

You only use the DllRegisterServer function when you provide a DLL for an OLE registration, but there are situations when you need to take action after registration. You may do so by using the /i argument.

You may, for example, give an input string (U) to the /i argument, which would concurrently call the DllInstall and DllRegisterServer methods.

The DllInstall function enables the regsvr32.exe utility to install a DLL in many ways and to perform multiple operations for a single DLL.

/i:U shell32.dll regsvr32

Adding a DLL to the system and running an install commandAdding a DLL to the system and running an install command

Without using the DllRegisterServer method, you may provide an install action.

You may just wish to install an OLE control rather than re-register it. If that’s the case, use the command below.

/n /i:U shell32.dll regsvr32

The/n argument in the command above prevents the installation method, DllInstall, from invoking the DllRegisterServer function for the shell32.dll DLL.

Only running an install command but not Adding a DLL to the systemOnly running an install command but not Adding a DLL to the system

Using regsvr32.exe to unregister an OLE Control

It’s a relief if you were able to register an OLE control without any issues. However, there may be times when you need to remove an OLE control because it is incompatible with others. Regsvr32.exe, thankfully, allows you to unregister and remove an OLE control.

Run regsvr32.exe with the /u argument to unregister and remove an OLE control. The msxml3.dll DLL was successfully removed, as seen in the GUI result below.

Pass the action string (U) to the /i argument to conduct an action along with unregistration. The regsvr32 command, for example, regsvr32 /i:action /U msxml3.dll, will then run the DllInstall function with that action as an uninstaller.

UnAdding a DLL to the systemUnAdding a DLL to the system

Managing Regsvr32.exe Errors

You’ve experienced successfully OLE Controls Registration, but what if the registration command comes across an error? There are a handful of errors that may appear when you attempt to manage controls. These messages may be cryptic at times but are broken down below to let you know what causes them.

FAIL_ARGS “No DLL name supplied” “Unrecognized flag” “Extra argument on command line” “This command is only acceptable when an OLE Custom Control project is open” It’s possible that a command-line parameter was mistyped.
FAIL_OLE “OleInitialize failed” is an error message. This indicates that the OLE subsystem was not correctly initialized.
FAIL_LOAD “LoadLibary(<dllname) failed>“ There might be a number of causes for this, including the lack of a dependant library, the DLL being unavailable due to permissions, or the file being lost.
FAIL ENTRY The entry point for ” was loaded, but it was not found. There doesn’t seem to be a.DLL or.OCX file” ” was loaded, but the entry point couldn’t be discovered” It’s possible that the file won’t be exported, or that there’s a faulty version in memory. Consider detecting and removing it using PView. The entry point for ” ” was loaded, but it was not found. may not be exportable, or there may be a corrupt version in memory. Consider detecting and removing it using WPS.” Infers that the DLL’s entry point, or function name, is missing.
FAIL_REG “<DLLEntryPoint> in <DLLName> failed“ The system failed to completely register the DLL despite all of the previous stages being completed.

Using PowerShell to extend the regsvr32.exe utility

Automation may be difficult since regsvr32.exe favors the GUI output. You may avoid this problem by wrapping the regsvr32.exe tool in a PowerShell function. You may execute regsvr32.exe as if it were a native PowerShell cmdlet by building a PowerShell function.

Take a look at the Invoke-RegSvr32 PowerShell function, for example. This method utilizes PowerShell to collect and handle the exit code generated by the regsvr32 program. You may even eliminate mistakes entirely by using an argument validation tool ahead of time!

To play around with the function below, create a new PowerShell console and paste the code into it. Then, as demonstrated below, you’ll be able to call the function.

How to Run a PowerShell Script From the Command Line is a related topic.

Function Invoke-RegSvr32 { <# .SYNOPSIS Wrap the regsvr32.exe Windows utility for OLE Controls Registration in a PowerShell function to aid in automation. .PARAMETER FilePath Specifies the DLL or control name to pass to regsvr32.exe, must be a valid file path. .PARAMETER InstallString Specify a string value to be passed as the pszCmdLine value in the DllInstall function when registering a control. .PARAMETER Unregister Unregister a previously registered control. .PARAMETER InstallOnly Do not register a control, only run the DllInstall function, which must also pass in an InstallString. .EXAMPLE PS> Invoke-RegSvr32 “C:\Windows\System32\msxml3.dll” #> [CmdletBinding()] Param ( [ValidateScript({ Test-Path -Path $_ -PathType ‘Leaf’ })] [String]$FilePath, [ValidateScript({-Not [String]::IsNullOrWhiteSpace($_)})] $InstallString, [Switch]$Unregister, [Switch]$InstallOnly ) Begin { # Error codes are documented in this Microsoft article # <> $ExitCodes = @{ 0 = “SUCCESS”; 1 = “FAIL_ARGS – Invalid Argument”; 2 = “FAIL_OLE – OleInitialize Failed”; 3 = “FAIL_LOAD – LoadLibrary Failed”; 4 = “FAIL ENTRY – GetProcAddress failed”; 5 = “FAIL_REG – DllRegisterServer or DllUnregisterServer failed.”; } } Process { If ($InstallOnly -And -Not $InstallString) { Write-Error “If you are running DllInstall by itself, an install string must be included.” Return } $Arguments = “/s{0}{1}{2} {3}” -f (($Unregister) ? ‘ /U’: ”), (($InstallString) ? ” /i:$InstallString”: ”), (($InstallOnly) ? ‘ /n’: ”), $FilePath Write-Verbose $Arguments Try { $Result = Start-Process -FilePath ‘regsvr32.exe’ -Args $Arguments -Wait -NoNewWindow -PassThru If ($Result.ExitCode -NE 0) { Write-Error $ExitCodes[$Result.ExitCode] } } Catch { Write-Error $_.Exception.Message } } }

A few examples of how to utilize the Invoke-RegSvr32 function are provided below.

# Try just running DllInstall with Verbose output against msxml3.dll. Invoke-RegSvr32 “C:WindowsSystem32msxml3.dll” Invoke-RegSvr32 “C:WindowsSystem32msxml3.dll” -InstallOnly -Verbose # Use Verbose output to quietly register msxml3.dll. Invoke-RegSvr32 “C:WindowsSystem32msxml3.dll” Invoke-RegSvr32 “C:WindowsSystem32msxml3.dll” -Verbose # Attempt to quietly register msxml3.dll, but no output Invoke-RegSvr32 “C:WindowsSystem32msxml3.dll” Invoke-RegSvr32 “C:WindowsSystem32msxml3.dll”

Using the PowerShell command Invoke-RegSvr32Using the PowerShell command Invoke-RegSvr32


You’ve figured out how to register and unregister DLLs, as well as how to deal with problems. Although you may not need to utilize regsrv32.exe for everyday activities, there are situations when you may need to register or unregister a DLL.

You could enhance PowerShell to account for even more checks and edge situations to take this even farther. You could even write a PowerShell function to get a list of the registered controls in the CLSID registry!

The “regsvr32 error” is a tool that can be used to register 32-bit Windows applications. This article will explain how and why to use the regsvr32.exe utility, as well as provide examples of its use.

Frequently Asked Questions

What is Regsvr32.exe process?

A: This is a legitimate process. Its used for running ActiveX, COM, and DCOM scripts on Windows systems.

Why do we need to register DLL?

A: DLL is a special file that Windows uses to communicate with programs. When Discord sends out messages, it needs the programs address so it can send those messages in the intended direction.

What type of files does Regsvr32 work with?

A: Regsvr32 works with all types of files, including text and multimedia.

Related Tags

  • regsvr32.exe download
  • regsvr32 windows 10
  • regsvr32 windows 10 64-bit
  • regsvr32.exe malware
  • regsvr32.exe /s

Table of Content