Ponto0n

How to type a number with multiple "periods" (IE: 11.0.14)

5 posts in this topic

#1 ·  Posted (edited)

Hi everyone,

I'm sure this is a stupid question, but I can't seem to find an answer. I have a script that I'm using to verify the correct version of software by using FileGetVersion. When I define the variable with the version number if I add another "." after 11.0 it doesn't seem to recognize the number anymore and I get an error saying I have an error in my expression. I'm sure I'm missing something simple, but I have no idea. Does anyone know what I have to do to allow me to type the full version number of 11.0.14?

 

Local $sFileVersion2 = FileGetVersion("C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe")
Local $sCorrectVersion = 11.0.14

If Not FileExists("C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe") Then
   RunWait("\\kmmdtmachine\c$\DeploymentShare$\Applications\Acrobat XI Standard\Acrobat.exe")
EndIf
If Not $sFileVersion2 = $sCorrectVersion Then
   RunWait("\\kmmdtmachine\c$\DeploymentShare$\Applications\Acrobat XI Standard Upgrade\Acrobat Upgrade.exe")
EndIf
If $sFileVersion2 = $sCorrectVersion Then
   MsgBox($MB_TOPMOST, "Version Correct", "Acrobat version" & $sFileVersion2 & "is install. This is the Correct Version", 5)
EndIf

 

Edited by Ponto0n

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Local $sFileVersion2 = StringReplace(FileGetVersion("C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe"), ".", "")
Local $sCorrectVersion = 11014

Get rid of the periods and do a comparison on two ints.

Edited by InunoTaishou

Share this post


Link to post
Share on other sites
4 minutes ago, InunoTaishou said:
Local $sFileVersion2 = StringReplace(FileGetVersion("C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe"), ".", "")
Local $sCorrectVersion = 11014

 

Thank you! Sadly, I never would've figured that out...

Share this post


Link to post
Share on other sites

Have a look in the help file at _VersionCompare() I think you will find it makes it a lot simpler.

Example:

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Global $sResult = ""
Global $sVersion1 = "3.3.10.17763"
Global $sVersion2 = FileGetVersion("C:\Program Files (x86)\Beyond Compare 3\BCompare.exe")
If NOT @error Then
    Global $iRes = _VersionCompare($sVersion1, $sVersion2)
    Switch $iRes
        Case 0
            $sResult = "Both versions are the same"
        Case 1
            $sResult = "$sVersion1 is greater (newer)"
        Case 1
            $sResult = "$sVersion1 is less (older)"
    EndSwitch
    MsgBox($MB_SYSTEMMODAL, '_VersionCompare Results', $sResult)
Else
    $sResult = "Could not ger version for file"
    MsgBox($MB_SYSTEMMODAL, '_VersionCompare Results', $sResult)
EndIf

 


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
39 minutes ago, Bowmore said:

Have a look in the help file at _VersionCompare() I think you will find it makes it a lot simpler.

Example:

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Global $sResult = ""
Global $sVersion1 = "3.3.10.17763"
Global $sVersion2 = FileGetVersion("C:\Program Files (x86)\Beyond Compare 3\BCompare.exe")
If NOT @error Then
    Global $iRes = _VersionCompare($sVersion1, $sVersion2)
    Switch $iRes
        Case 0
            $sResult = "Both versions are the same"
        Case 1
            $sResult = "$sVersion1 is greater (newer)"
        Case 1
            $sResult = "$sVersion1 is less (older)"
    EndSwitch
    MsgBox($MB_SYSTEMMODAL, '_VersionCompare Results', $sResult)
Else
    $sResult = "Could not ger version for file"
    MsgBox($MB_SYSTEMMODAL, '_VersionCompare Results', $sResult)
EndIf

 

Thanks for posting! Interesting, I didn't know this function existed. What you posted makes sense to me, kind of. What's posted in the help file confuses the hell out of me. I'm extremely new at scripting. I'm only using it to automate some software installs so the advanced stuff totally escapes me!

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