Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get property file version in item name of a file

Status
Not open for further replies.

OrionCookies

Programmer
May 5, 2005
43
US
Hi all,
I know i can get file version with get fileversion method. But file version i am trying to get is different than getting fileversion.
I mean, if i right click and click on version tab, that version is different than just below under ITEM NAME, there is a file version, ...
I am trying to get file version of a file under ITEM NAME..

Need help on this..

thanks in advance...
 
You can try seeing if you can get the info using Shell.Application with something like this.

Code:
Option Explicit

GetFileDetails "C:\temp\app.exe"

Sub GetFileDetails(strFilePath)
    Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
    Dim strParentFolder : strParentFolder = objFSO.GetParentFolderName(strFilePath)
    Dim strFileName : strFileName = objFSO.GetFileName(strFilePath)
    Dim objShell : Set objShell = CreateObject("Shell.Application")
    Dim objFolder : Set objFolder = objShell.NameSpace(strParentFolder)
    Dim objFile : Set objFile = objFolder.ParseName(strFileName)
    Dim intCount, strHeader, strValue
    For intCount = 0 To 47
        strHeader = objFolder.GetDetailsOf(objFolder.Items, intCount)
        strValue = objFolder.GetDetailsOf(objFile, intCount)
        If strValue <> "" Then 
            WScript.Echo strHeader & ":" & Space(40 - Len(strHeader)) & strValue
        End If
    Next
End Sub

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Hi dm4ever thanks for your reply,
It didn't give me fileversion for the item name
 
Well the only other thing I can think of is to try DSOFile.

Though primarily for MS Office docs, it CAN be used for other file types. Make sure you read both links since one of them contains the old way of using it and the other the new.

1. (download DLL)
2. 3.
--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Hi,
I had figured it out...here is my code in case someone needed..


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


For Each objFile in colFiles

If objFile.Version = "5.1.1" Then
Wscript.Echo "Version 5.1.1 = " & objFile.Version
Elseif objFile.Version = "4.1 Sr 2.19.1" Then
Wscript.Echo "Version 4.1 Sr 2.19.1 = " & objFile.Version
Else
Wscript.Echo "Version unknown = " & objFile.Version
End If
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top