GetFileVersion Method

Office VBScript

Microsoft® Visual Basic® Scripting Edition GetFileVersion Method  Scripting Run-Time Reference 
Version 5 

See Also                  Applies To


Description
Returns the version number of a specified file.
Syntax
object.GetFileVersion(pathspec)

The GetVersion method syntax has these parts:

Part Description
object Required. Always the name of a FileSystemObject.
pathspec Required. The path (absolute or relative) to a specific file.

Remarks
The GetFileVersion method returns a zero-length string ("") if pathspec does not end with the named file or if the file does not contain version information.

The following example illustrates use of the GetFileVersion method:

Function GetVersion(PathSpec)
  Dim fso, temp
  Set fso = CreateObject("Scripting.FileSystemObject")
  temp = fso.GetFileVersion(PathSpec)
  If Len(temp) Then 
    GetVersion = temp
  Else
    GetVersion = "No version information available."
  End If
End Function

Note  The GetFileVersion method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.