Source language: Translate to:

Get file version

General questions about NeoBook

Moderator: Neosoft Support

Get file version

Postby stu » Thu Feb 04, 2016 4:10 am

Hi all,

Is there a way of getting the version of an EXE file?

Sort of like using FileOpenBox and getting "1.1.0.0" of the selected file?
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Get file version

Postby Tony Kroos » Thu Feb 04, 2016 4:30 am

Code: Select all
    {NeoBook Function}
    Version=5,80
    Language=VBScript
    Param=[%1]|FileName|Full path to file
    Param=[%2]|Variable|Result variable
    {End}
    Set objFS = CreateObject("Scripting.FileSystemObject")
    nbSetVar "[%2]", objFS.GetFileVersion(objFS.GetFile("[%1]"))
    Set objFS = Nothing
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: Get file version

Postby stu » Thu Feb 04, 2016 4:35 am

Tony Kroos wrote:
Code: Select all
    {NeoBook Function}
    Version=5,80
    Language=VBScript
    Param=[%1]|FileName|Full path to file
    Param=[%2]|Variable|Result variable
    {End}
    Set objFS = CreateObject("Scripting.FileSystemObject")
    nbSetVar "[%2]", objFS.GetFileVersion(objFS.GetFile("[%1]"))
    Set objFS = Nothing


Yeah, I came to ask a bit too quick... I went the vbscript way too, slightly different:

Code: Select all
' Get file version
Function GetVersion(DriveSpec)
   Dim fso, temp
   Set fso = CreateObject("Scripting.FileSystemObject")
   temp = fso.GetFileVersion(DriveSpec)
   If Len(temp) Then
      GetVersion = temp
   Else
      GetVersion = "No version information available."
   End If
End Function

publication.nbSetVar "[%2]", GetVersion("[%1]")


From here

Thanks!
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Get file version

Postby Tony Kroos » Thu Feb 04, 2016 4:39 am

You always make things more complex than it should )
And you may just check if [result] is empty in nb, instead of comparing it against error text strings. Keep VBS as small as possible, it takes time to execute it.
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: Get file version

Postby stu » Thu Feb 04, 2016 6:20 am

Tony Kroos wrote:You always make things more complex than it should


You sound exactly like my ex
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron