Get executables' version and details
eesheesh opened this issue · 2 comments
eesheesh commented
Example code:
Set shell = CreateObject("Shell.Application")
Set folder = shell.Namespace("C:\Windows")
Set file = folder.ParseName("notepad.exe")
For i = 0 to 1000
If folder.GetDetailsOf(file, i) <> "" Then _
Wscript.Echo i & ": " & folder.GetDetailsOf(file, i)
Next
Based on http://stackoverflow.com/questions/2976734/how-to-retrieve-a-files-product-version-in-vbscript.
eesheesh commented
This doesn't work reliably over the network, so it isn't feasible as long as we rely on VBScript.
BTW, getting attribute -1 would be the best, because it includes all relevant info.
eesheesh commented
Actually, looks like it can be done with WMI, according to this:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select Name, Version from CIM_Datafile Where Name = 'c:\\windows\\system32\\notepad.exe' OR Name = 'c:\\windows\\system32\\cmd.exe'")
For Each objFile in colFiles
Wscript.Echo objFile.Name & vbTab & objFile.Version
Next
Reopening!