Jump to content

need help with: find file version installed


Recommended Posts

hi ppl, i have looked around with no luck to find a way to check the version of a file installed on a system, then display it in a message box or some other control. can anyone point me to the right direction or show me an example of a script that does that? will be much appreciated.

Link to comment
Share on other sites

ok so i gut the version of the file i am looking for

$FileVersion = FileGetVersion($FileInstallPath)

now i display it to a messagebox and shows fine.

MsgBox(0, "File in question:", $FileVersion)

Now when i display it in a label control nothing shows

GUICtrlSetData($label, $FileVersion)

can someone help me with this please?

Edited by Tiboi
Link to comment
Share on other sites

Now when i display it in a label control nothing shows

Can you post actual script for view whats going?

It works for me:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("TEST FORM", 633, 447, 192, 124)
$Label1 = GUICtrlCreateLabel("", 128, 72, 388, 57)
$filegetversion=FileGetVersion(@ProgramFilesDir&"\Internet Explorer\iexplore.exe") ;%programfiles%\Internet Explorer\iexplore.exe
GUICtrlSetData($Label1,$filegetversion)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
[size="5"] [/size]
Link to comment
Share on other sites

here is the code

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

$GUI = GUICreate("")
$lblInfo = GUICtrlCreateLabel("", 10, 10, 200, 20)
CHECK_VERSION()
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func CHECK_VERSION() ;<--
    Local $version, $szDrive, $szDir, $szFName, $szExt, $szPath
    If FileExists(@ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe") Then
        $szPath = @ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe"
        GUICtrlSetData($lblInfo, "Autoit " & "v" & $version & " Is Installed")
    Else
        GUICtrlSetData($lblInfo, "Autoit Is Not Installed!!")
    EndIf
    _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt)
    $AutoitexePath = $szDrive & $szDir & "AutoIt3.exe"
    $version = FileGetVersion($AutoitexePath)

    MsgBox(0, "", $version)
EndFunc
Link to comment
Share on other sites

  • Developers

here is the code

What are you expecting? you first set the control info and then get the version of the file.

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 comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

$GUI = GUICreate("")
$lblInfo = GUICtrlCreateLabel("", 10, 10, 200, 20)
CHECK_VERSION()
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
WEnd

Func CHECK_VERSION() ;<--
    Local $version, $szDrive, $szDir, $szFName, $szExt, $szPath
    If FileExists(@ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe") Then
    $szPath = @ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe"
    GUICtrlSetData($lblInfo, "Autoit " & "v " & FileGetVersion($szPath) & " Is Installed")
    Else
    GUICtrlSetData($lblInfo, "Autoit Is Not Installed!!")
    EndIf



EndFunc ; <== CHECK_VERSION()

[size="5"] [/size]
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

$GUI = GUICreate("")
$lblInfo = GUICtrlCreateLabel("", 10, 10, 200, 20)
CHECK_VERSION()
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
WEnd

Func CHECK_VERSION() ;<--
    Local $version, $szDrive, $szDir, $szFName, $szExt, $szPath
    If FileExists(@ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe") Then
    $szPath = @ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe"
    GUICtrlSetData($lblInfo, "Autoit " & "v " & FileGetVersion($szPath) & " Is Installed")
    Else
    GUICtrlSetData($lblInfo, "Autoit Is Not Installed!!")
    EndIf



EndFunc ; <== CHECK_VERSION()

yes this works but notice in your script you found the file version of "AutoIt3Help.exe" where as in my script i wanted to find the version of "autoit.exe". my script will be used in a situation where i find the version of the main file in a directory so that i can know what features to expect in another file in the same directory
Link to comment
Share on other sites

this code shows it working in the message box but not in the label.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

$GUI = GUICreate("")
$lblInfo = GUICtrlCreateLabel("", 10, 10, 200, 20)
CHECK_VERSION()
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func CHECK_VERSION() ;<--
    Local $version, $szDrive, $szDir, $szFName, $szExt, $szPath, $AutoitexePath
    If FileExists(@ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe") Then
        $szPath = @ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe"
        GUICtrlSetData($lblInfo, "Autoit " & "v" & FileGetVersion($AutoitexePath) & " Is Installed")
    Else
        GUICtrlSetData($lblInfo, "Autoit Is Not Installed!!")
    EndIf
    _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt)
    $AutoitexePath = $szDrive & $szDir & "AutoIt3.exe"
    ;$version = FileGetVersion($AutoitexePath)
    MsgBox(0, "", FileGetVersion($AutoitexePath))
EndFunc   ;==>CHECK_VERSION

i dont understand why

Edited by Tiboi
Link to comment
Share on other sites

this code shows it working in the message box but not in the label.

...

i dont understand why

Here is a summary below of what is needed to achieve the correct result. It is sometimes known as a plan. The summary has been made to look like comments that you can add to your existing code or if you created from new.

; Get AutoIt version using FileGetVersion()
; If AutoIt exists, then display AutoIt version in GUI label
; Msgbox AutoIt version to compare with the result in GUI label

Read it a few times to ensure it is logical. Now add each line of comment to your existing code which matches the section of code and check if they are in correct order. If not in a correct order, then rearrange your comment with corresponding code so it is in correct order.

Hint:

If I added the comments to your existing code, the comment order would look something like this

; If AutoIt exists, then display AutoIt version in GUI label
...
; Get AutoIt version using FileGetVersion()
...
; Msgbox AutoIt version to compare with the result in GUI label
...

The comment order is different. Read the comments now and you may notice something illogical about the order of them.

:mellow:

Link to comment
Share on other sites

ok i got this to work. solution was to put

_PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt)
withen the if and elseif statements so i have it twice in one function. it works so thats ok for now. thanks everyone

and this is the original code i was working on

Func vBoxVersion()
    Local $vBoxPath, $szPath, $szDrive, $szDir, $szFName, $szExt
    If FileExists(@ProgramFilesDir & "\Oracle\VirtualBox\VBoxManage.exe") Then;<--if this file exists then store it in $vbPath
        $szPath = @ProgramFilesDir & "\Oracle\VirtualBox\VBoxManage.exe" ;<--if above exist this is where it will be stored
        _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt)
        $vBoxPath = $szDrive & $szDir & "virtualbox.exe"
        GUICtrlSetData($lblvBoxVersion, "Oracle VirtualBox " & "v" & FileGetVersion($vBoxPath) & " Is Installed") ; <-- Get vBox version using FileGetVersion()
    ElseIf FileExists(@ProgramFilesDir & "\Sun\VirtualBox\VBoxManage.exe") Then
        $szPath = @ProgramFilesDir & "\Sun\VirtualBox\VBoxManage.exe"
        _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt)
        $vBoxPath = $szDrive & $szDir & "virtualbox.exe"
        GUICtrlSetData($lblvBoxVersion, "Sun VirtualBox " & "v" & FileGetVersion($vBoxPath) & " Is Installed")
    Else
        GUICtrlSetData($lblvBoxVersion, "VirtualBox Is Not Installed!!")
    EndIf
EndFunc   ;==>vBoxVersion
Edited by Tiboi
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...