Tiboi Posted May 27, 2010 Share Posted May 27, 2010 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 More sharing options...
PsaltyDS Posted May 27, 2010 Share Posted May 27, 2010 FileGetVersion() See help file for example. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Tiboi Posted May 27, 2010 Author Share Posted May 27, 2010 FileGetVersion()See help file for example.thanks checking it now Link to comment Share on other sites More sharing options...
Tiboi Posted May 27, 2010 Author Share Posted May 27, 2010 (edited) 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 May 27, 2010 by Tiboi Link to comment Share on other sites More sharing options...
Fire Posted May 27, 2010 Share Posted May 27, 2010 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 More sharing options...
Tiboi Posted May 27, 2010 Author Share Posted May 27, 2010 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 More sharing options...
Developers Jos Posted May 27, 2010 Developers Share Posted May 27, 2010 (edited) here is the codeWhat are you expecting? you first set the control info and then get the version of the file. Edited May 27, 2010 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 More sharing options...
Fire Posted May 27, 2010 Share Posted May 27, 2010 #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 More sharing options...
Tiboi Posted May 27, 2010 Author Share Posted May 27, 2010 #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 More sharing options...
Tiboi Posted May 27, 2010 Author Share Posted May 27, 2010 What are you expecting? you first set the control info and then get the version of the file.hi did you get my pm? Link to comment Share on other sites More sharing options...
Tiboi Posted May 27, 2010 Author Share Posted May 27, 2010 (edited) 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 May 27, 2010 by Tiboi Link to comment Share on other sites More sharing options...
jaberwacky Posted May 27, 2010 Share Posted May 27, 2010 i dont understand whyThere are just a few minor mistakes in your code. Fix them and it'll work fine. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
MHz Posted May 28, 2010 Share Posted May 28, 2010 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. Link to comment Share on other sites More sharing options...
Tiboi Posted May 28, 2010 Author Share Posted May 28, 2010 (edited) 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 May 28, 2010 by Tiboi Link to comment Share on other sites More sharing options...
Tiboi Posted May 28, 2010 Author Share Posted May 28, 2010 this is one of the programs i was working on its complete in 7 days from starting to learn programming. i feel good YAY! enjoyhttp://www.mediafire.com/?zytnwyzywmn Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now