¿Cómo puedo obtener una lista de directorios de DLL con ProductName y ProductVersion?
-
22-07-2019 - |
Pregunta
Cuando miro un directorio en el Explorador de Windows, puedo ver una propiedad ProductName y ProductVersion para las DLL en ese directorio.
Necesito exportar esta lista de DLL con ProductName y ProductVersion a un archivo de texto.
Si hago c: \ > dir * .dll > test.log
, test.log no tiene ProductName y ProductVersion.
¿Podría alguien ayudarme a exportar estas propiedades a un archivo junto con el nombre del archivo?
Incluso si es una herramienta gratuita o algún otro conmutador dir
, será útil.
Solución
Usando VBScript puede hacer lo siguiente:
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
Otros consejos
PowerShell es tu amigo aquí, y es gratis (como en cerveza) disponible de Microsoft.
La siguiente es una línea para escupir el nombre del producto, la versión del producto y el nombre del archivo de todos los archivos DLL en el directorio de Windows en test.log:
OK, es una línea larga , pero sigue siendo solo una línea en el símbolo del sistema.
Los fanáticos de PowerShell probablemente podrán condensar lo anterior aún más. ¡Tenga en cuenta que PowerShell nos permite usar la biblioteca de clases base .Net (o incluso sus propios ensamblajes) como System.Diagnostics.FileVersionInfo desde la línea de comandos!
Si aún no ha jugado con PowerShell, tiene un regalo en la tienda, especialmente si es un desarrollador de .Net :)
Puede hacerlo con bastante facilidad con una aplicación .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);
}
}
Obviamente, tendría que agregar una función que recuperara todos los archivos en un directorio específico.
Agregar una versión VB.Net a la lista:
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
Llámelo por: CreateLog (" c: \ log.txt " ;, " c: \ windows " ;, " *. dll ")
Editar: patrón de búsqueda agregado.
No puedo hablar con este software en absoluto, pero parece hacer lo que estás buscando:
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
Interesante, no conocía esta función GetDetailsOf.
Me preguntaba sobre el tamaño arbitrario ...
No estoy seguro de cuál es el límite, que parece variar entre carpetas o al menos la configuración del usuario o algo así, así que hice algo más 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
Para responder la pregunta, puede verificar cuándo detail
es igual a la información que está buscando y solo muestra estos valores.