View Single Post
Old 06-24-2009   #5 (permalink)
Paul Randall


 
 

Re: How to get the file version value

Hi mayayana
I'm working (occasionally) on a script that recurses through all folders on
a drive that are accessible to the FSO, and which compares the folder's
files and subfolders collections to the items available in the equivalent
shell folder items collection, noting the things that are in one of the two
objects (fso vs shell.app) and not in the other. So far I have found that
shell.app folders do not reveal hidden items, even though the items
collection filter property has a masking bit associated with 'hidden',
according to the MS Online docs. Maybe I haven't figured out how to use
this 'hidden' bit.

Do you have a script that demonstrates the 'undependable tool' shortcomings
that you talk about, on WXP? I don't have an older system to play on. Is
it only hidden files or are there others that don't show up for you?

Oops. I just tried groups.googling for 'shell folder items filter
group:*.scripting.vbscript', and found a sample script that includes the
hidden files. Here is the script with a few modifications:

Const iFolders = 32, iFiles = 64, iHidden = 128
Set oShell = CreateObject("Shell.Application")
sPath = "D:\VBScript\Test Filter Hidden"
sFilter = "*.txt"
Set oFolder = oShell.NameSpace(sPath)
Set oFolderItems = oFolder.Items()
oFolderItems.Filter iFolders + iFiles, sFilter
WScript.Echo "Non hidden filtered .TXT files count = " & oFolderItems.Count
oFolderItems.Filter iFolders + iFiles + iHidden, sFilter
WScript.Echo "Hidden filtered .TXT files count = " & oFolderItems.Count
if oFolderItems.count = 0 then WScript.Quit
For Each oItem In oFolderItems
WScript.Echo oItem.Path
Next

I created a single hidden .txt file in the folder with my script, and it
produced the following results:
Non hidden filtered .TXT files count = 0
Hidden filtered .TXT files count = 1
D:\VBScript\Test Filter Hidden\New Text Document.txt

It seems counterintuitive for the first of the following statements get a
collection of all non-hidden files and the second statement to expand that
collection to include hidden files while also contracting the collection to
only those files with an extension of .txt.
Set oFolderItems = oFolder.Items()
oFolderItems.Filter iFolders + iFiles + iHidden, sFilter

My Shell32.dll is file/product version 6.00.2900.5622, and OS is WXP Home
SP3.

-Paul Randall

"mayayana" <mayaXXyana@xxxxxx> wrote in message
news:%23MXbPnQ9JHA.3544@xxxxxx
Quote:

> Adding to the other posts:
>
> The FileSystemObject GetFileVersion method
> is the easiest, if you just want the file version.
>
> The WMI method provides more, but not all
> version info.
>
> The Shell.Application method varies greatly
> depending on OS. It's also an undependable tool
> that does not actually see all files.
>
> A 4th method is here:
> www.jsware.net/jsware/scripts.php5#fvinfo
>
> It's a VBScript class that you can paste into
> any script. It works by "cutting out the middleman".
> While each of the above methods calls an
> available object to get what that object can provide,
> this class reads directly from the file's version info.
> section, in the file's resource table. The other objects
> get their info. from the same place, with a
> sidetrack through the Windows API. By reading from
> the resource table directly the class can return
> anything that's been recorded there -- including
> Comment, FileDescription, etc. -- and not just the
> parts made avaiable through a given scripting object.
>
>
Quote:

>> How do I get the value of the file version or product version property of
> a
Quote:

>> file in a VB script?
>>
>
>
>

My System SpecsSystem Spec