如何获取具有ProductName和ProductVersion的DLL的目录列表?

时间:2021-04-20 00:12:32

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

当我在Windows资源管理器中查看目录时,我可以看到该目录中DLL的ProductName和ProductVersion属性。

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

我需要将带有ProductName和ProductVersion的DLL列表导出到文本文件中。

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

如果我执行c:\> dir * .dll> test.log,则test.log没有ProductName和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.

即使它是一个免费软件工具或其他一些目录开关,这将是有用的。

6 个解决方案

#1


1  

Using VBScript you could do the following:

使用VBScript,您可以执行以下操作:

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

#2


2  

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

PowerShell是你的朋友 - 它可以从微软免费获得(如啤酒)。

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:

以下是将Windows目录中所有dll的产品名称,产品版本和文件名吐出到test.log中的内容:

dir c:\windows\*.dll | % {[System.Diagnostics.FileVersionInfo]::GetVersionInfo($_)} | % { $_.ProductName + ", " + $_.ProductVersion + ", " + $_.FileName} > 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!

PowerShell afficionados可能会进一步压缩上述内容。请注意,PowerShell允许我们从命令行使用.Net基类库(甚至是您自己的程序集),例如System.Diagnostics.FileVersionInfo!

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

如果您尚未使用PowerShell,那么您可以在商店中享受美食 - 特别是如果您是.Net开发人员:)

#3


1  

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

您可以使用.NET应用程序轻松地完成此操作。

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.

显然,您必须添加一个检索指定目录中所有文件的函数。

#4


1  

Adding a VB.Net version to the list:

将VB.Net版本添加到列表中:

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")

通过以下方式调用它:CreateLog(“c:\ log.txt”,“c:\ windows”,“* .dll”)

Edit:Added searchpattern.

#5


0  

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

#6


0  

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:

有意思,我不知道这个GetDetailsOf函数。我想知道任意大小...我不确定什么是限制,这似乎在文件夹或至少用户设置之间有所不同,所以我做了一些更灵活的东西:

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.

要回答这个问题,您可以检查详细信息何时等于您要查找的信息,并仅显示这些值。

#1


1  

Using VBScript you could do the following:

使用VBScript,您可以执行以下操作:

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

#2


2  

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

PowerShell是你的朋友 - 它可以从微软免费获得(如啤酒)。

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:

以下是将Windows目录中所有dll的产品名称,产品版本和文件名吐出到test.log中的内容:

dir c:\windows\*.dll | % {[System.Diagnostics.FileVersionInfo]::GetVersionInfo($_)} | % { $_.ProductName + ", " + $_.ProductVersion + ", " + $_.FileName} > 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!

PowerShell afficionados可能会进一步压缩上述内容。请注意,PowerShell允许我们从命令行使用.Net基类库(甚至是您自己的程序集),例如System.Diagnostics.FileVersionInfo!

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

如果您尚未使用PowerShell,那么您可以在商店中享受美食 - 特别是如果您是.Net开发人员:)

#3


1  

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

您可以使用.NET应用程序轻松地完成此操作。

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.

显然,您必须添加一个检索指定目录中所有文件的函数。

#4


1  

Adding a VB.Net version to the list:

将VB.Net版本添加到列表中:

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")

通过以下方式调用它:CreateLog(“c:\ log.txt”,“c:\ windows”,“* .dll”)

Edit:Added searchpattern.

#5


0  

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

#6


0  

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:

有意思,我不知道这个GetDetailsOf函数。我想知道任意大小...我不确定什么是限制,这似乎在文件夹或至少用户设置之间有所不同,所以我做了一些更灵活的东西:

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.

要回答这个问题,您可以检查详细信息何时等于您要查找的信息,并仅显示这些值。