How can I get a directory listing of DLLs with ProductName and ProductVersion?

StackOverflow https://stackoverflow.com/questions/332005

  •  22-07-2019
  •  | 
  •  

Question

When I look at a directory in Windows Explorer, I can see a ProductName and ProductVersion property for the DLL's in that directory.

I need to export this DLL list with ProductName and ProductVersion into a text file.

If I do c:\>dir *.dll > test.log, the test.log does not have the ProductName and ProductVersion.

Could someone help me to get these properties exported to a file along with the filename?

Even if it is a freeware tool or some other dir switch, that will be useful.

Was it helpful?

Solution

Using VBScript you could do the following:

Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace ("C:\Scripts")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim arrHeaders(40)

For i = 0 to 40
    arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next

For Each strFileName in objFolder.Items
    For i = 0 to 40
        Wscript.echo arrHeaders(i) & ": " & objFolder.GetDetailsOf (strFileName, i) 
    Next
    Wscript.Echo
Next

OTHER TIPS

PowerShell is your friend here - and it's freely (as in beer) available from Microsoft.

The following is a one liner to spit out the product name, product version and file name of all the dlls in the windows directory into test.log:

dir c:\windows\*.dll | % {[System.Diagnostics.FileVersionInfo]::GetVersionInfo($_)} | % { $_.ProductName + ", " + $_.ProductVersion + ", " + $_.FileName} > test.log

OK, so it's a long line - but it is still just one line at the command prompt.

PowerShell afficionados will probably be able to condense the above still further. Note that PowerShell allows us to use the .Net base class library (or even your own assemblies) such as System.Diagnostics.FileVersionInfo from the command line!

If you haven't played with PowerShell yet, you have a treat in store - particularly if you are a .Net developer :)

You can do this fairly easily with a .NET application.

using System;
using System.Diagnostics;

static class MainClass
{
    static void Main(string[] args)
    {

        FileVersionInfo info = FileVersionInfo.GetVersionInfo("c:\\test.txt");

        // Display version information.
        Console.WriteLine("Checking File: " + info.FileName);
        Console.WriteLine("Product Name: " + info.ProductName);
        Console.WriteLine("Product Version: " + info.ProductVersion);
        Console.WriteLine("Company Name: " + info.CompanyName);

    }
}

Obviously, you'd have to add a function that retrieved all the files in a specified directory.

Adding a VB.Net version to the list:

Sub CreateLog(ByVal Logfile As String, ByVal PathToLog As String, Optional ByVal SearchPattern As String = "*.*")

    Dim FileInfo As FileVersionInfo
    Dim ret As String = ""
    For Each File As String In IO.Directory.GetFiles(PathToLog, SearchPattern)
        FileInfo = FileVersionInfo.GetVersionInfo(File)
        If FileInfo.ProductName & FileInfo.ProductVersion <> "" Then
            ret &= FileInfo.ProductName & ", " & FileInfo.ProductVersion & vbCrLf
        End If
    Next

    IO.File.WriteAllText(Logfile, ret)

End Sub

Call it by: CreateLog("c:\log.txt", "c:\windows", "*.dll")

Edit:Added searchpattern.

I cannot speak to this software at all, but this appears to do what you're looking for:

http://www.softpedia.com/get/Programming/Other-Programming-Files/STRFINFO.shtml

SYNTAX
~~~~~~
StrFInfo[.EXE] ExeDllOcxFileName  [Property1  [Property2 ...]]

COMMON PROPERTIES
~~~~~~~~~~~~~~~~~
FileDescription  FileVersion InternalName
OriginalFileName ProductName ProductVersion
CompanyName LegalCopyRight $Translation

Interesting, I didn't know this GetDetailsOf function.
I wondered about the arbitrary size...
I am not sure what is the limit, which seem to vary between folders or at least user settings or something, so I made something more flexible:

Set shell = CreateObject("Shell.Application")
Set folder = shell.Namespace("D:\Documents")

Set fso = CreateObject("Scripting.FileSystemObject")
For Each fileName in folder.Items
  i = 0
  emptyNb = 0
  Do
    detail = folder.GetDetailsOf(folder.Items, i)
    If detail = "" Then
      emptyNb = emptyNb + 1
    Else
      detailValue = folder.GetDetailsOf(fileName, i)
      If detailValue <> "" Then
        Wscript.Echo i & " " & detail & ": " & detailValue
      End If
      emptyNb = 0
    End If
    i = i + 1
  Loop While emptyNb < 3 ' Arbirary, adjust as you see fit
  detailValue = folder.GetDetailsOf(fileName, -1)
  If detailValue <> "" Then
    Wscript.Echo "Tooltip:" & vbCrLf & detailValue
  End If
  Wscript.Echo
Next

To answer the question, you can check when detail is equal to the info you are looking for and only display these values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top