Detecting DLL version number using script

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

How can I determine the version number of a DLL using a script? VBScript solutions are preferred if there is no better way.

+2


source to share


2 answers


You can use the object FileSystemObject

to access the file system and GetFileVersion

get version information for a file.

You requested 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 subfolders
  For Each oSubFolder In Folder.SubFolders
    PrintDLLVersions oSubFolder
  Next
End Sub

      

Using:

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


eg:.

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

Output example:

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
...
+4


source


EDIT I think this one is the source I referenced

This is the script I am using, sorry, but I don't remember where. (So ​​reader, if this started out as your script, take it a step further). It uses FileSystemObject which can get the version directly.



@echo off
setlocal
set vbs="%temp%\filever.vbs"
set file=%1

echo Set oFSO = CreateObject("Scripting.FileSystemObject") >%vbs%
echo WScript.Echo oFSO.GetFileVersion(WScript.Arguments.Item(0)) >>%vbs%

for /f "tokens=*" %%a in (
'cscript.exe //Nologo %vbs% %file%') do set filever=%%a

del %vbs%
echo Full file version of %file% is: %filever%

for /f "tokens=2 delims=. " %%a in ("%filever%") do set secondparam=%%a
set splevel=%secondparam:~0,1%
echo SP level is: %splevel%

endlocal
pause

      

+2


source







All Articles