September 20th, 2018

What do the various regsvr32 exit codes mean?

The exit codes for the regsvr32 program are currently as follows:

Exit code Meaning
0 Success
1 Error parsing command line
2 OleInitialize failed
3 LoadLibrary failed
4 GetProcAddress failed
5 Registration function failed

This information is included for diagnostic and troubleshooting purposes. I don’t think the values are contractual.

The regsvr32 program basically does five things, and the exit codes correspond to each of those steps.

  1. Parse the command line to see what it’s being asked to do.
  2. Initialize OLE.
  3. Load the library.
  4. Find the function to be called. The command line options specify which function to look for. Could be Dll­Register­Server, Dll­Unregister­Server, or even Dll­Install.
  5. Call it.

Steps 4 and 5 may be repeated if the command line options indicate that multiple functions should be called.

If something goes wrong, the regsvr32 program reports the error details to the user, and the exit code summarizes which step it got stuck at. Future versions of regsvr32 may add additional steps, or change the order of the steps, which would trigger renumbering. The exit code is for diagnostic and troubleshooting purposes, so you can try to figure out why something went wrong.

We’ll put this information to use next time.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.