?
Solved

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

Posted on 2010-03-31
7
Medium Priority
?
1,970 Views
Last Modified: 2012-05-09
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

0
Comment
Question by:advcom
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 9

Expert Comment

by:Karen
ID: 29301698

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

0
 
LVL 10

Expert Comment

by:peetm
ID: 29317442
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.
0
 

Author Comment

by:advcom
ID: 29358073
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"
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
LVL 13

Expert Comment

by:Daz_1234
ID: 29678106
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
0
 
LVL 9

Accepted Solution

by:
Karen earned 2000 total points
ID: 30073189
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)

0
 

Author Comment

by:advcom
ID: 31994417
Thanks snowberry, you hit it right on button. Works perfectly
0
 
LVL 13

Expert Comment

by:Daz_1234
ID: 32132278
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.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Suggested Courses

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question