Jump to content

Unable to read FileGetVersion()


Recommended Posts

I am having a weird issue.

Both my INI file and App1.exe properties version are 1.0.2345.17509

But when I validate, it gives me the msgbox "False". I also tried changing the Filegetversion() to RegRead but it is still the same.

I am not sure but could it be a false reading of binary digits?

Local $Test_LocalFile = "C:\Program Files\Test\App1.exe"
Local $Test_LocalFile_Ver = FileGetVersion($Test_LocalFile, "ProductVersion")
Local $Test_SourceFile_Ver = IniRead("c:\Test.ini", "Apps", "App1", "")

If $Test_LocalFile_Ver = $Test_SourceFile_Ver Then
    MsgBox(0, "", "True")
Else
    MsgBox(0, "", "False")
EndIf

 

Link to comment
Share on other sites

Use the _VersionCompare function for comparing file versions.  

#include <Misc.au3>

Local $Test_LocalFile = "C:\Program Files\Test\App1.exe"
Local $Test_LocalFile_Ver = FileGetVersion($Test_LocalFile, "ProductVersion")
Local $Test_SourceFile_Ver = IniRead("c:\Test.ini", "Apps", "App1", "")

If _VersionCompare($Test_LocalFile_Ver, $Test_SourceFile_Ver) = 0 Then
    MsgBox(0, "", "True")
Else
    MsgBox(0, "", "False")
EndIf

 

Adam

Link to comment
Share on other sites

@Jos, I am already running as #RequireAdmin.

@AdamUL, it give the same False result.

I have loads of other validations which are all correct. It is just this file which shows opposite result. 🤨

 

But when I change it as:

If _VersionCompare($Test_LocalFile_Ver, $Test_SourceFile_Ver) = 0 Or _VersionCompare($Test_LocalFile_Ver, $Test_SourceFile_Ver) = 1 Then
    MsgBox(0, "", "True")
Else
    MsgBox(0, "", "False")
EndIf

So _VersionCompare works in this case. But as per help file it as 3 validations which is why we can't put only = 0 and Else.

 0 - Both versions equal
 1 - Version 1 greater
-1 - Version 2 greater

 

End of the line, this works as per my need.

Thank you.

Edited by DigDeep
Link to comment
Share on other sites

Make that elegant (only one function call):

; verbose
Local $res = _VersionCompare($Test_LocalFile_Ver, $Test_SourceFile_Ver)
Switch $res
    Case -1
        MsgBox(0, "", "Older")
    Case 0
        MsgBox(0, "", "Same")
    Else
        MsgBox(0, "", "Newer")
EndSwitch

; compact alternative
Local $res = _VersionCompare($Test_LocalFile_Ver, $Test_SourceFile_Ver)
MsgBox(0, "", $res < 0 ? "Older" : ($res = 0 ? "Same" : "Newer"))

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...