Finding the First DLL File in the Path

Today the question came up how do we find which DLL file that a program is calling.   This is an older server that has had a couple of upgrades & patches applied, without any kind of cleanup.  The issue is that there are multiple versions of a DLL file stored with in the directories listed in the PATH environment variable.

This is a DLL file that is not registered in the Windows registry.  The vendor’s software support informed us that we are using the wrong version of the DLL file for our error.

Our challenge was to figure out which DLL file is being called if the server has a large PATH environment variable?

Kudos to paxdiablo from for posting the answer that helped us.  Now, where he found this answer is something you’ll have to ask him.

In our case, we had multiple versions of the “sqljdbc.dll” file on this server.  The program would not work because it could not find the specific version of this DLL file it needs.

Using the following string, we were able to find where the first DLL file is located in the PATH:

c:\> for %i in ( < filename> ) do @echo %~$PATH:i

EXAMPLE:     c:\> for %i in (sqljdbc.dll) do @echo %~$PATH:i


Resolution:  There are many ways to correct this issue.  We choose to move the directory with the correct version of the DLL file toward to front of the PATH environment variable.

Possible Error:  The first try we attempted this on a different server, and the response was “ECHO is on”.  This occurs because the file is not found in the PATH.  Once we added the directory to the PATH environment variable, the program worked on this other server.







Categories: Windows

Comments are closed.