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?

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

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

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KarenAnalyst programmerCommented:

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)

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

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.
advcomAuthor Commented:
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"
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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:

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 ...


... 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,
KarenAnalyst programmerCommented:
Sorry... my code stopped too early... Description seems to be index 36. Try this:

dim objShell
dim objFolder
dim arrHeader

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

arrHeader = objFolder.GetDetailsOf(objFolder.Items, 36)

Wscript.echo arrHeader & ": " & objFolder.GetDetailsOf(objFolderItem, 36)


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
advcomAuthor Commented:
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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.