ur

How to get file version

5 posts in this topic

How to get the thrid number of a file version.

Example: Let's say I have a file with below properties.

I want only the third number like here it is 1941 as highlighted.

Is there any built in function to get it??

asdsd.png

Share this post


Link to post
Share on other sites



You can use StringSplit for splitting the return of FileGetVersion:

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the file version of the AutoIt executable.
    Local $sFileVersion = FileGetVersion(@AutoItExe)
    Local $aSplit=StringSplit($sFileVersion,'.')
    If IsArray($aSplit) Then MsgBox($MB_SYSTEMMODAL, "", $aSplit[3])
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites

yeah I tried the below one and working.Used the inputs from Anoop.

 

#include <MsgBoxConstants.au3>
#include <Array.au3>

$sFilePath = FileOpenDialog("Select a file to read attributes",@ScriptDir,"All (*.*)")
MsgBox(0,$sFilePath,getFileVersionBuildNumber($sFilePath))

Func getFileVersionBuildNumber($sFilePath)

$sStringName = "FileVersion"
Local $sStringValue = FileGetVersion($sFilePath, $sStringName)

If Not @error Then
    ;Display the property value.
    $b = StringSplit ( $sStringValue, '.' )[3]
    return $b
Else
    ;If error, display an error message.
    MsgBox($MB_ICONERROR, "", "Error when getting " & '"' & $sStringName  & '"')
EndIf

EndFunc

 

Share this post


Link to post
Share on other sites
10 minutes ago, ur said:

yeah I tried the below one and working.Used the inputs from Anoop.

 

#include <MsgBoxConstants.au3>
#include <Array.au3>

$sFilePath = FileOpenDialog("Select a file to read attributes",@ScriptDir,"All (*.*)")
MsgBox(0,$sFilePath,getFileVersionBuildNumber($sFilePath))

Func getFileVersionBuildNumber($sFilePath)

$sStringName = "FileVersion"
Local $sStringValue = FileGetVersion($sFilePath, $sStringName)

If Not @error Then
    ;Display the property value.
    $b = StringSplit ( $sStringValue, '.' )[3]
    return $b
Else
    ;If error, display an error message.
    MsgBox($MB_ICONERROR, "", "Error when getting " & '"' & $sStringName  & '"')
EndIf

EndFunc

 

Great to know that!!! :)

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

  • Similar Content

    • ripdad
      WMIC_GET
      By ripdad
      Here is  another WMIC script that parses properties from various alias classes.
      ie: COMPUTERSYSTEM, CDROM, IDECONTROLLER, DISKDRIVE, etc.
      Download:  WMIC_GET.au3
       
    • Vivaed
      List files in folder, delete all but newest version
      By Vivaed
      I am trying to read all the files in a folder, then whatever file is newest, keep only that one and delete the rest.
      Example files:  (these all have version numbers embedded in them, I dont want to rely on the file name)
      Faint.exe
      Faint-v2.0.exe
      Faint-v3.0.exe
      Faint-v4.0.exe
       
      What I have so far:
      #include <File.au3> RemoveOldFiles() ConsoleWrite(FileGetVersion("C:\WB Resources\FAINT_DONT_LINK_THESE\Faint-v4.0.0.exe") &@CRLF) Func RemoveOldFiles() Local $aFileList = _FileListToArray("C:\WB Resources\FAINT_DONT_LINK_THESE\", "*.exe",$FLTA_FILES) For $i = 0 To UBound($aFileList) - 1 $aFileVersion = FileGetVersion($aFileList[$i]) ConsoleWrite($aFileList[$i] & @CRLF) ConsoleWrite($aFileVersion & @CRLF) Next EndFunc OUTPUT: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\bot\ownCloud\WellBeats\Delete Old Files\delete-test.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop 3 0.0.0.0 a.exe 0.0.0.0 b.exe 0.0.0.0 Faint-v4.0.0.exe 0.0.0.0 4.0.0.18 <-- This is the correct file version.... +>07:34:26 AutoIt3.exe ended.rc:0 +>07:34:26 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6647 Not sure what I am missing here?
      Thanks!
    • ur
      How to compare file or folder contents
      By ur
      Generally we will use tools like Winmerge or Beyond Compare for this purpose.
      Are there any UDF or libraries available in AutoIT to compare any two files or folder contents.
    • tremolux66
      Exclusive file locking - SOLVED
      By tremolux66
      I've run into the problem where multiple script processes writing to a log file at the same time can interfere with one another. That is, file writes using FileWriteLine are not atomic, so a line of text from one process can have fragments of text from other processes mixed in with it. Exclusive file-locking should take care of the problem.
      Looking through the standard UDFs, I see that _WinAPI_LockFile is available, but according to the MSDN documentation it doesn't block - it returns immediately if the lock can't be obtained - and there doesn't seem to be a UDF for the LockFileEx function. I considered writing my own UDF for LockFileEx, but some aspects (e.g., creating the OVERLAPPED structure and its members) look too complex for the amount of time I have available. I think approximating LockFileEx using LockFile could solve my problem, but I'd like to keep it simple while still working reliably. I'm not confident that (e.g.) a simple retry loop to simulate blocking will be adequate.
      Any suggestions for a simple way to achieve exclusive file-locking with blocking?
    • Rapidnxit
      [solved] send multiple files by email from a file list
      By Rapidnxit
      Hi! I want to send by mail some files with a certain extension (.xml in my case). These files are located in the script folder. First, I thought to use _FileListToArrayRec function to have a list of these files. But than I don't know how to send them all at once. I know that I can attach multiple files in this way: path1;path2;path3; etc.  and so I have tried to make a string of this type with the path of the files (with a for loop) but It doesn't attach any file (only instructions.txt). How could I do? ( what I did is just an idea, if there's something better that would be great) Thanks!
      $aArrayXml = _FileListToArrayRec(@ScriptDir, "*.xml", $FLTAR_FILES) _ArrayDisplay($aArrayXml, "LIST XML") $LenghtArrayXml = UBound($aArrayXml) If ($LenghtArrayXml > 2) Then For $i = 2 To $LenghtArrayXml - 1 $temp = "&@ScriptDir&""\"&$aArrayXml[$i]&";"&"""" $XmlListFile = $XmlListFile & $temp Next EndIf $XmlListFile = StringTrimLeft($XmlListFile, 1) if($LenghtArrayXml = 2)Then $rc =_INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ScriptDir&"\"&$aArrayXml[1]&";"&@ScriptDir&"\instructions.txt", $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) Else $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ScriptDir&"\"&$aArrayXml[1]&$XmlListFile&@ScriptDir&"\instructions.txt", $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) EndIf