GetFileVersion Method

Switch View :
ScriptFree
Scripting Runtime Library
GetFileVersion Method

Returns the version number of a specified file.


                      object.GetFileVersion(pathspec) 
Arguments

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

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

The following example illustrates the use of the GetFileVersion method.

JScript
function ShowFileName(filespec){
   var fso, s = "";
   fso = new ActiveXObject("Scripting.FileSystemObject");
   s += fso.GetFileVersion(filespec);
   return(s);
}

VBScript
Function GetVersion(DriveSpec)
   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

See Also

Reference

Community Content

StockTrader
A little correction...

The article contains an error:

The 4th line of the VBScript example is:
 temp = fso.GetFileVersion(pathspec)
but if should be
 temp = fso.GetFileVersion(DriveSpec)becuase the variable pathspec is undefined.
Regards,
Marco S. Zuppone