Sign in to follow this  
Followers 0
Wyleyrabbit

need help getting file version

5 posts in this topic

Hi Everyone!

I'm new here, and new to AutoIt. What an amazingly simple yet useful language AutoIt is. Kudos to the developers. :lmao:

I'm writing a script to check the currently installed version of various programs. For my test case, I'm checking the current version of Firefox to see if it needs to be upgraded.

Unfortunately, FileGetVersion seems to return some unexpected results. For example, version "1.5" is the current version, but FileGetVersion returns it as "1.8.20051.11116"

$fileversion = FileGetVersion("C:\Program Files\Mozilla Firefox\firefox.exe")

By right-clicking the exe file and hitting "properties" then the "version" tab at the top, I see what's going on. The "File Version" may indeed is "1.8.20051.11116" so I guess it's the "Product Version" I'm really after, since that says "1.5".

After doing some googling, I figured out that one can probably do a DLL call to get the information I'm after. Unfortunately, I don't come from a windows programming background (most of my coding has been in Perl on *nix) and I therefore have zero experience talking to DLLs.

I managed to put the following code to work, which happily returns a "0". My suspicion is that the "0" simply means that the DLL call was successful, but I'm not sure of that either.

$file = @ProgramFilesDir & "\Mozilla Firefox\firefox.exe"

$dll = DllOpen("version.dll")

$result = DllCall($dll,"str","ProductVersion","str",$file)

DllClose($dll)

MsgBox(0,"version",$result)

Thanks for any help or suggestions.

Cheers.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

umm i think there is a registry key saying your current firefox version... gimme a sec to find it

here we are

$ver = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla.org\Mozilla","CurrentVersion")

--did this help?

~cdkid

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

umm i think there is a registry key saying your current firefox version... gimme a sec to find it

here we are

$ver = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla.org\Mozilla","CurrentVersion")
Hey. Thanks, but not quite.

That returns "1.8b4" on my machine (which has Firefox version 1.5).

Besides that, I'd like to be able to read the "Product Version" of other programs as well. Any further ideas?

Cheers,

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try this:

$ver = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox","CurrentVersion")
$status = 1
$x = 1
While $status <> 0 or $status2 <> 0
    $trimed = StringLeft($ver,$x)
    $status = StringIsFloat ( $trimed)
    $status2 = StringIsInt ( $trimed)
    $x = $x + 1
wend
msgbox(0,"The version number is:","The version number of firefox is: " & $trimed)

It could probably be done more efficiently than that, i just wrote that script up real fast. It seems to work though. I hope it helps.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

Try this:

$ver = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox","CurrentVersion")
$status = 1
$x = 1
While $status <> 0 or $status2 <> 0
    $trimed = StringLeft($ver,$x)
    $status = StringIsFloat ( $trimed)
    $status2 = StringIsInt ( $trimed)
    $x = $x + 1
wend
msgbox(0,"The version number is:","The version number of firefox is: " & $trimed)

It could probably be done more efficiently than that, i just wrote that script up real fast. It seems to work though. I hope it helps.

Ok, that works brilliantly! Thanks. :lmao:

Now the trick is going to be trying to figure out which programs I can just use the built-in "FileGetVersion()" command and which ones we can't.

So, is it even possible to do it the way I was initially trying to do it? By making a call to the version.dll file? Could be a very useful thing for me (and others) to know how to do. Anyone? Anyone? Bueller?

Cheers

Share this post


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
Sign in to follow this  
Followers 0