Detecting DLL version number using script
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 to share
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 to share