{"id":243,"date":"2013-06-27T02:16:19","date_gmt":"2013-06-27T02:16:19","guid":{"rendered":"http:\/\/www.theSQLReport.com\/?p=243"},"modified":"2013-06-27T02:21:21","modified_gmt":"2013-06-27T02:21:21","slug":"finding-the-first-dll-file-in-the-path","status":"publish","type":"post","link":"https:\/\/www.theSQLReport.com\/?p=243","title":{"rendered":"Finding the First DLL File in the Path"},"content":{"rendered":"<p>Today the question came up how do we find which DLL file that a program is calling.\u00a0\u00a0 This is an older server that has had a couple of upgrades &amp; patches applied, without any kind of cleanup.\u00a0 The issue is that there are multiple versions of a DLL file stored with in the directories listed in the PATH environment variable.<\/p>\n<p>This is a DLL file that is not registered in the Windows registry.\u00a0 The vendor&#8217;s software support informed us that we are using the wrong version of the DLL file for our error.<\/p>\n<p>Our challenge was to figure out which DLL file is being called if the server has a large PATH environment variable?<\/p>\n<p>Kudos to <a title=\"paxdiablo from stackoverflow.com\" href=\"http:\/\/stackoverflow.com\/users\/14860\/paxdiablo\" target=\"_blank\">paxdiablo<\/a> from <a title=\"Stack Overflow\" href=\"http:\/\/stackoverflow.com\/questions\/519410\/find-the-path-of-notepad-exe-and-mspaint-exe\" target=\"_blank\">stackoverflow.com<\/a> for posting the answer that helped us.\u00a0 Now, where he found this answer is something you&#8217;ll have to ask him.<\/p>\n<p>In our case, we had multiple versions of the &#8220;sqljdbc.dll&#8221; file on this server.\u00a0 The program would not work because it could not find the specific version of this DLL file it needs.<\/p>\n<p>Using the following string, we were able to find where the first DLL file is located in the PATH:<\/p>\n<p>c:\\&gt; for %i in ( &lt; filename&gt; ) do @echo %~$PATH:i<\/p>\n<p>EXAMPLE:\u00a0\u00a0\u00a0\u00a0 c:\\&gt; for %i in (sqljdbc.dll) do @echo %~$PATH:i<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileFound.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-245\" title=\"FileFound\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileFound.jpg\" alt=\"\" width=\"702\" height=\"150\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileFound.jpg 702w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileFound-300x64.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileFound-210x44.jpg 210w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/p>\n<p>Resolution:\u00a0 There are many ways to correct this issue.\u00a0 We choose to move the directory with the correct version of the DLL file toward to front of the PATH environment variable.<\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileNotFound.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-247\" title=\"ECHO is on\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileNotFound.jpg\" alt=\"\" width=\"425\" height=\"164\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileNotFound.jpg 425w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileNotFound-300x115.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/06\/FileNotFound-210x81.jpg 210w\" sizes=\"(max-width: 425px) 100vw, 425px\" \/><\/a><\/p>\n<p>Possible Error:\u00a0 The first try we attempted this on a different server, and the response was &#8220;ECHO is on&#8221;.\u00a0 This occurs because the file is not found in the PATH.\u00a0 Once we added the directory to the PATH environment variable, the program worked on this other server.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today the question came up how do we find which DLL file that a program is calling.\u00a0\u00a0 This is an older server that has had a couple of upgrades &amp; &hellip; <a class=\"readmore\" href=\"https:\/\/www.theSQLReport.com\/?p=243\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":245,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-243","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows"],"_links":{"self":[{"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/243"}],"collection":[{"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=243"}],"version-history":[{"count":25,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":273,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions\/273"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/media\/245"}],"wp:attachment":[{"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}