37

When you are registering a DLL in old machines (Windows XP), regsrv always says that the registration was sucessful. This happens even if the user doesn't have permission to register.

With the name of the dll, is there a command that I can run at the command line to verify if a DLL is installed?

neves
  • 1,160
  • 2
  • 11
  • 16

3 Answers3

27

I've found this link: How can I tell whether a DLL has been registered?:

Given that DLL registration can encompass arbitrary operations, there is no general-purpose way of determining whether registration has taken place for an arbitrary DLL.

To determine whether a DLL has been registered, you need to bring in domain-specific knowledge. If you know that a DLL registers a COM object with a particular CLSID, you can check whether that CLSID is indeed registered.

OK, it is impossible, but DLLs usually register themselves creating an entry in the register. A workaround is to:

  1. First you have to discover the COM GUID of the DLL. If you have one machine where it is already registered, you can:
    1. Open regedit and search for your DLL filename
    2. If it is registered, you will find filename under a key that is under the TypeLib. The key will look like: {9F3DBFEE-FD77-4774-868B-65F75E7DB7C2}
  2. Now that you know the DLL GUID, you can search for it with this command in a DOS prompt: reg query HKCR\CLSID | find /i "{9F3DBFEE-FD77-4774-868B-65F75E7DB7C3}"

A better answer would allow me to find the GUID directly from the file before it was registered. At least this way you can create a script to install and verify if it was successfully installed.

neves
  • 1,160
  • 2
  • 11
  • 16
  • 6
    You don't actually need to know the GUID beforehand. A simpler approach would be to search the Registry for the DLL *filename*: if that name is listed under any one of those GUID keys, then yes, the DLL has indeed been registered. – Massimo Feb 19 '14 at 19:58
  • @Massimo: but how I would search for it? In which key? It can wrongly display in the shell history (e.g., tried to register without being a admin) – neves Feb 19 '14 at 21:00
  • Under HKCR, obviously :) Or at the very least under HKLM. User-specific things (like shell history) are under HKCU. – Massimo Feb 19 '14 at 22:13
  • @Massimo: if you put an answer here with the shell command to search for it, I'll mark it as the correct answer. – neves Feb 20 '14 at 14:20
  • It's the same as yours: use `REG QUERY` to look for the DLL file name. – Massimo Feb 20 '14 at 14:26
  • If the exact DLL filename isn't in the registry, is that a guarantee that the DLL isn't registered? I got a DLL (audio plugin) that works only if it's installed via NSIS installer--if you extract it manually, it wont work. Registry search gives nothing. I susected the DLL needs to be registered but seems not the case. – bryc Sep 19 '19 at 16:20
21

I needed to check whether a DLL with particular name is registered and I used this command in my BAT:

reg query HKLM\SOFTWARE\Classes /s /f whatever.dll
if errorlevel 1 goto DLL_MISSING

If with errorlevel sent control to the label whenver reg query found nothing. You may need to change the part of the registry where you search (in my case HKLM'..., the more specific path the faster, otherwise it takes really long).

The output can be processed if necessary, GUID for the entry can be obtained, but that is out of scope of reg query command.

virgo47
  • 311
  • 2
  • 3
3

To find registry entries (and optionally COM objects) for a DLL from the command line, a combination of the answers by @virgo47 and @neves worked best for me.

  1. Find registry entries that contain the DLL name. These entries typically use GUIDs as their keys.

    reg query HKLM\SOFTWARE\Classes /s /f whatever.dll

  2. (optional) Find COM objects that have been registered for these GUIDs. (Using /s /f "{GUID}" should be faster than | findstr /i "{GUID}". And | find /i "{GUID}" appears to be a typo (but I cannot write comments on Serverfault yet).)

    reg query HKCR\CLSID /s /f "{9F3DBFEE-FD77-4774-868B-65F75E7DB7C3}"

Orafu
  • 31
  • 1