您可以使用该FileSystemObject对象访问文件系统及其GetFileVersion方法来获取文件版本信息。
您要求一个VBScript示例,因此您在这里:
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
Run Code Online (Sandbox Code Playgroud)
用法:
> cscript // nologo script-file.vbs 文件夹 > 外文件
例如:
> cscript // nologo dll-list.vbs C:\ Dir> dll-list.txt
样本输出:
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 ...