Jump to content

FileGetVersion() error with $FV_FILEVERSION and $FV_PRODUCTVERSION


Recommended Posts

$FV_FILEVERSION and $FV_PRODUCTVERSION are different fields in details of a file, but FileGetVersion() shows in both cases only the productversion (87.0). Is there a chance to get the correct value of fileversion (87.0.0.7747)? 

image.png.516cc4c448e9a94639f3dc25afcc2435.png

 

 

Edited by HJL
() missing
Link to post
Share on other sites
Posted (edited)
2 hours ago, Nine said:

Hmm, tested on Win7 and Win10.  Both work fine.

I use Win10. Where can I find the definition of this function? Perhaps it is a problem with the system language (german)?

Local $sTest = "C:\Program Files (x86)\AutoIt3\autoit3.exe"

MsgBox(0, "Test FileGetVersion" , "FileVersion:" & @TAB & FileGetVersion($sTest, "FileVersion") & _
    @CRLF & "ProductVersion:" & @TAB & FileGetVersion($sTest, "ProductVersion"))

image.png.543cda9ece983069c84ddcfe6f7fe94d.png

 

Edited by HJL
Link to post
Share on other sites
  • Developers

I get the same which makes sense when looking at the Version PE Information as that is what they have put in the StringFileInfoblock:

1 VERSIONINFO
FILEVERSION 86,0,1,7739
PRODUCTVERSION 86,0,1,0
FILEOS 0x4
FILETYPE 0x2
{
BLOCK "StringFileInfo"
{
    BLOCK "000004b0"
    {
        VALUE "Comments", ""
        VALUE "LegalCopyright", "©Firefox and Mozilla Developers; available under the MPL 2 license."
        VALUE "CompanyName", "Mozilla Corporation"
        VALUE "FileDescription", "Firefox"
        VALUE "FileVersion", "86.0.1"
        VALUE "ProductVersion", "86.0.1"
        VALUE "InternalName", "Firefox"
        VALUE "LegalTrademarks", "Firefox is a Trademark of The Mozilla Foundation."
        VALUE "OriginalFilename", "firefox.exe"
        VALUE "ProductName", "Firefox"
        VALUE "BuildID", "20210310152336"
    }
}

BLOCK "VarFileInfo"
{
    VALUE "Translation", 0x0000 0x04B0  
}
}

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
19 minutes ago, Jos said:

I get the same which makes sense when looking at the Version PE Information as that is what they have put in the StringFileInfoblock:

Jos

I have put my code and a screenshot in the thread above. Even autoit3.exe shows a difference. Perhaps FileGetVersion() does not show what "Details" show?

Link to post
Share on other sites
  • Developers

You aren't getting what I am telling you: The version shown by  FileGetVersion()  are retrieved from BLOCK "StringFileInfo", which could be different than de version info you see at the top of the VERSION section ofthe PE Header! ( Check again the posted PE header of FireFox! )

AutoIt3.exe shows: 

FileGetVersion("C:\Program Files (x86)\AutoIt3\AutoIt3.exe",$FV_FILEVERSION) = 3, 3, 14, 5
FileGetVersion("C:\Program Files (x86)\AutoIt3\AutoIt3.exe",$FV_PRODUCTVERSION) = 3, 3, 14, 5

Which is correct as that is what is in the VERSION:

1 VERSIONINFO
FILEVERSION 3,3,14,5
PRODUCTVERSION 3,3,14,5
FILEOS 0x4
FILETYPE 0x0
{
BLOCK "StringFileInfo"
{
    BLOCK "080904b0"
    {
        VALUE "CompanyName", "AutoIt Team"
        VALUE "Comments", "http://www.autoitscript.com/autoit3/"
        VALUE "FileDescription", "AutoIt v3 Script"
        VALUE "FileVersion", "3, 3, 14, 5"
        VALUE "InternalName", "AutoIt3.exe"
        VALUE "LegalCopyright", "©1999-2018 Jonathan Bennett & AutoIt Team"
        VALUE "OriginalFilename", "AutoIt3.exe"
        VALUE "ProductName", "AutoIt v3 Script"
        VALUE "ProductVersion", "3, 3, 14, 5"
    }
}

BLOCK "VarFileInfo"
{
    VALUE "Translation", 0x0809 0x04B0  
}
}

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Hi Jos,
I am a little lacking the background to understand this problem. Can you help me?
1. Where can I find the AutoIt source code of the FileGetVersion () function? Just to understand how it works.
2. How can I look at the PE header of any exe file?
4. What is the BLOCK "StringFileInfo"?


My problem is, that, despite our best efforts, neither Chrome nor Edge update automatically and I consider that to be a high risk. I have therefore written an AutoIt program that writes the versions of Chrome, Edge and Firefox to a log file for all clients each time the computer is started. If I see there that a client is again without an update, which happens occasionally but not always, then I intervene manually. But for this I need the true current version data of the three browsers. I can only read the actual version from the registry under HKCU if the respective user has started the browser on this client after the last update. Until then, there is still the previous version to see.

Have a nice weekend!

Hans

 

Link to post
Share on other sites
  • Developers
Posted (edited)
7 hours ago, HJL said:

1. Where can I find the AutoIt source code of the FileGetVersion () function? Just to understand how it works.

Not available as it is closed, but it is similar to the available: _WinAPI_VerQueryValue() UDF.

7 hours ago, HJL said:

2. How can I look at the PE header of any exe file?

Just download reshacker and open the EXE with it. Then look at the VERSIONInfo block.

7 hours ago, HJL said:

4. What is the BLOCK "StringFileInfo"?

What happened with 3.? :) ... but the Internet is your friend as I am not going to try to explain stuff for which a lot of detailed information is available.

When you need the Fileversion or Productversion from the static Version part , you could use this piece of code which contains a UDF that extracts it:

#include <WinAPIRes.au3>

$EXE_FileName = "C:\Program Files\Mozilla Firefox\FireFox.exe"
ConsoleWrite('+ FileGetVersion = ' & FileGetVersion($EXE_FileName, $FV_FILEVERSION) & @CRLF)
ConsoleWrite('+ FileGetVersion = ' & FileGetVersion($EXE_FileName, $FV_PRODUCTVERSION) & @CRLF)
ConsoleWrite('+ _FileGetHeaderVersion = ' & _FileGetHeaderVersion($EXE_FileName, $FV_FILEVERSION) & @CRLF)
ConsoleWrite('+ _FileGetHeaderVersion = ' & _FileGetHeaderVersion($EXE_FileName, $FV_PRODUCTVERSION) & @CRLF)

Func _FileGetHeaderVersion($EXE_FileName, $Name = "FileVersion")
    ; ===============================
    ; Get Header version
    ; ===============================
    $Versionptr = 0
    Local $VersionBlockLen = _WinAPI_GetFileVersionInfo($EXE_FileName, $Versionptr, -1)
    ; construct the needed first part of the VERSIONINFO block
    Local $p_VS_VERSIONINFO = DllStructCreate( _
            "short  wLength;" & _
            "short  wValueLength;" & _
            "short  wType;" & _
            "wchar  szKey[16];" & _
            "wchar  Padding1[1];" & _
            "DWORD dwSignature;" & _
            "DWORD dwStrucVersion;" & _
            "DWORD dwFileVersionMS;" & _
            "DWORD dwFileVersionLS;" & _
            "DWORD dwProductVersionMS;" & _
            "DWORD dwProductVersionLS;" & _
            "DWORD dwFileFlagsMask;" & _
            "DWORD dwFileFlags;" & _
            "DWORD dwFileOS;" & _
            "DWORD dwFileType;" & _
            "DWORD dwFileSubtype;" & _
            "DWORD dwFileDateMS;" & _
            "DWORD dwFileDateLS" & _
            "", $Versionptr) ;

    If $Name = "ProductVersion" Then
        $dwProductVersionMS = Hex(DllStructGetData($p_VS_VERSIONINFO, "dwProductVersionMS"), 8)
        $dwProductVersionLS = Hex(DllStructGetData($p_VS_VERSIONINFO, "dwProductVersionLS"), 8)
        Return Dec(StringMid($dwProductVersionMS, 1, 4)) & "." & Dec(StringMid($dwProductVersionMS, 5, 4)) & "." & Dec(StringMid($dwProductVersionLS, 1, 4)) & "." & Dec(StringMid($dwProductVersionLS, 5, 4))
    Else
        $dwFileVersionMS = Hex(DllStructGetData($p_VS_VERSIONINFO, "dwFileVersionMS"), 8)
        $dwFileVersionLS = Hex(DllStructGetData($p_VS_VERSIONINFO, "dwFileVersionLS"), 8)
        Return Dec(StringMid($dwFileVersionMS, 1, 4)) & "." & Dec(StringMid($dwFileVersionMS, 5, 4)) & "." & Dec(StringMid($dwFileVersionLS, 1, 4)) & "." & Dec(StringMid($dwFileVersionLS, 5, 4))
    EndIf
EndFunc   ;==>FileGetHeaderVersion

This is the output of the script:

+ FileGetVersion = 87.0
+ FileGetVersion = 87.0
+ _FileGetHeaderVersion = 87.0.0.7747
+ _FileGetHeaderVersion = 87.0.0.0

This is the info shown is reshacker:

1 VERSIONINFO
FILEVERSION 87,0,0,7747
PRODUCTVERSION 87,0,0,0
FILEOS 0x4
FILETYPE 0x2
{
BLOCK "StringFileInfo"
{
    BLOCK "000004b0"
    {
        VALUE "Comments", ""
        VALUE "LegalCopyright", "©Firefox and Mozilla Developers; available under the MPL 2 license."
        VALUE "CompanyName", "Mozilla Corporation"
        VALUE "FileDescription", "Firefox"
        VALUE "FileVersion", "87.0"
        VALUE "ProductVersion", "87.0"
        VALUE "InternalName", "Firefox"
        VALUE "LegalTrademarks", "Firefox is a Trademark of The Mozilla Foundation."
        VALUE "OriginalFilename", "firefox.exe"
        VALUE "ProductName", "Firefox"
        VALUE "BuildID", "20210318103112"
    }
}

BLOCK "VarFileInfo"
{
    VALUE "Translation", 0x0000 0x04B0  
}
}

Jos 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

As Jos mentioned (just read his full post) if you specify the "stringname" it gets this from StringFileInfo Block, however if you don't define stringname it appears to get the FileVersion header (which I believe is what you're trying to achieve).

Local $sTest = "C:\Program Files\Mozilla Firefox\Firefox.exe"

ConsoleWrite("FileVersion($sTest)                 : " & FileGetVersion($sTest) & @CRLF & _
    'FileVersion($sTest, "FileVersion")  : ' & FileGetVersion($sTest, "FileVersion") & @CRLF & _
    'FileVersion($sTest, "ProductVersion : ' & FileGetVersion($sTest, "ProductVersion") & @CRLF)

Returns the following for me:

FileVersion($sTest)                 : 78.5.0.7619
FileVersion($sTest, "FileVersion")  : 78.5.0
FileVersion($sTest, "ProductVersion : 78.5.0

 

Edited by Subz
Link to post
Share on other sites
  • Developers

It is correct that FileGetVersion() will get the "\FileVersion" info and whenever parameter 2 is provided the information for "\StringFileInfo\LANG\ParameterValue" is returned, but there is a slight difference in your both results as the ProductionVersion of the header is different from the "StringfileInfo" block and not possible to retrieve.
The script was to demonstrate how to get information from the VERSION INFO PE Header block.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Thanks to all for your help - I have learned a lot.

FileGetVersion() without second param works fine for me with chrome.exe, edge.exe, firefox.exe and msegdedriver.exe,

but chromedriver.exe and geckodriver.exe seem to be without version information. I searched with reshacker and filealyzer.

 

 

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...