Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting a DLL version number using a script

I would like to write a script that can recursively scan the DLLs in a directory and generate a report of all of their version numbers.

How can I detect the version number of a DLL using a script? VBScript solutions are preferred, unless there is a better way.

like image 350
sourcenouveau Avatar asked Jul 03 '26 09:07

sourcenouveau


1 Answers

You can use the FileSystemObject object to access the file system and its GetFileVersion method to obtain the file version information.

You asked for a VBScript example, so here you are:

Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
PrintDLLVersions oFSO.GetFolder(WScript.Arguments.Item(0))

Sub PrintDLLVersions(Folder)
  Dim oFile, oSubFolder

  ' Scan the DLLs in the Folder
  For Each oFile In Folder.Files
    If UCase(oFSO.GetExtensionName(oFile)) = "DLL" Then
      WScript.Echo oFile.Path & vbTab & oFSO.GetFileVersion(oFile)
    End If
  Next

  ' Scan the Folder's subfolders
  For Each oSubFolder In Folder.SubFolders
    PrintDLLVersions oSubFolder
  Next
End Sub

Usage:

> cscript //nologo script-file.vbs folder > out-file

e.g.:

> cscript //nologo dll-list.vbs C:\Dir > dll-list.txt

Sample output:

C:\Dir\foo.dll 1.0.0.1
C:\Dir\bar.dll  1.1.0.0
C:\Dir\SubDir\foobar.dll    4.2.0.0
...
like image 146
Helen Avatar answered Jul 05 '26 16:07

Helen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!