Link to home
Start Free TrialLog in
Avatar of advcom
advcom

asked on

How do I get the description property of a file in vbscript or vb6

I have used FSO and WMI with vbscript to retrieve file information such as company, date created, size, etc. However, I cannot figure out how to get the description property of a file. That property seems to be left out, even though I can view it fine within the file properties Window. Any idea on how to retrieve it?
'HERE IS MY CODE FOR THE OTHER PROPERTIES

strFile = "c:\file.exe"        
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select * from CIM_Datafile Where name = '" & strFile & "'")

'PROPERTIES OF FILE
For Each objFile In colFiles
	MsgBox("Size=" & objFile.FileSize)
	MsgBox("Creation Date=" & objFile.CreationDate)
	MsgBox("Company=" & objFile.Manufacturer)
	MsgBox("Version=" & objFile.Version)
Next

Open in new window

Avatar of Karen
Karen
Flag of Australia image


Replace with your directory in objShell.Namespace, and your file name in objFolder.ParseName:

dim objShell
dim objFolder
dim arrHeaders(34)
dim i

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\")
set objFolderItem = objFolder.ParseName("file.exe")

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

For i = 0 to 33
        Wscript.echo i & vbtab & arrHeaders(i) & ": " & objFolder.GetDetailsOf(objFolderItem, i)
Next

Is this the 'Description' as in, if you look at \Windows\Explorer.exe you see 'Windows Explorer'?  If 'yes', I'm not sure you'll be able to get at that (I don't know of a mechanism) without using the Windows' API.
Avatar of advcom
advcom

ASKER

snowberry, I tried you example and it does bring back properties, but not the description property.
peetm, I do need to retrieve the description property as you describe. For e.g. when you hover over c:\windows\explorer.exe, it says "Description: Windows Explorer"
Hi advcom,

What you want is not directly possible in VBScript.

The attached VBScript is something I have used before to get the information from exe files, written by a helpful chap from jsware.

I downloaded it from here:
http://www.jsware.net/jsware/scripts.php5#fvinfo

When you look at the script the top part is a demonstration - remove the .txt from the filename then drag an exe onto the vbs, (try Explorer.exe), and you'll get something like the info in the image below.

To use the info info in your own script follow the sample syntax and paste everything below the line containg ...

BEGIN Classes HERE

... into the bottom of your own script to include all the class.

Note that when it refers to 'Version Info'  it means all the info available from the Version tab of the file properties, not just the version number.

Hope this helps,
Daz
File-Version-Info.vbs.txt
test.JPG
ASKER CERTIFIED SOLUTION
Avatar of Karen
Karen
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of advcom

ASKER

Thanks snowberry, you hit it right on button. Works perfectly
Nice one snowberry,  at some point MS must have extended the GetDetailsOf method since you never used to be able to get that detail:  The properties only used to be 0 to 34, now they are 0 to 40.


Daz.