Jump to content

read script version from my script

Recommended Posts

Hi all,

i need your advice or idea how can i create auto update to my script.

my big problem is how to create and read version number from compiled script.

i tried use get version function but it always return the autoit version (which always the same...)

using the version in script name can work (i.e my_script_1.0.1.exe) but im looking for more elegant way.

can I push version or number to compilation description or something like that? (then use get version from auto it)


Link to post
Share on other sites

both methods return me the autoit version ( 3.3.X.X)

however after playing with compilation advance options i succeed to push product number to file properties. (it also can be seen from windows file properties )

now when i use FileGetVerion(@ScriptFullPath)

i get the right number i pushed, and can compare it.


Link to post
Share on other sites


Here is my solution for automatic update of my programs.

Perhaps you might do something like this.

; _Softwareupdate UDF include file      by Forumer100
; Example:
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=Y ;P
#AutoIt3Wrapper_Run_After=%scriptfile%.exe SoftwareUpdate
#include '_SoftwareUpdate.au3'
_SoftwareUpdate('O:\Data\Homepage\forumer\ftp\software\', 'HTTP://MyDomain.de/forumer/ftp/software/')
; insert your working code here
; please copy %scriptfile%.exe and %scriptfile%.exe.ini to remote HTTP server after compile.
Func _SoftwareUpdate($LocalServerURL, $RemoteServerURL)
If Not @Compiled Then Return SetError(100)
Local $EXE = @ScriptName
Local $INI = @ScriptName & ".ini"
If StringInStr($CmdLineRaw, "SoftwareUpdate") Then
  IniWrite($INI, "SoftwareUpdate", "Version", FileGetVersion($EXE, "FileVersion"))
  IniWrite($INI, "SoftwareUpdate", "Timestamp", FileGetTime($EXE, 0, 1))
  FileCopy($EXE, $LocalServerURL & $EXE, 1)
  FileCopy($INI, $LocalServerURL & $INI, 1)
  Exit Beep(440, 200)
$ahost = StringSplit($RemoteServerURL, "://", 1)
If IsArray($ahost) Then $ahost = StringSplit($ahost[2], "/")
If @error Then Return SetError(100 + @error)
For $i = 1 To 10
  If Not Ping($ahost[1]) Then ContinueLoop
If @error Then Return SetError(100 + @error)
If InetGet($RemoteServerURL & $INI, $INI, 1) = 0 Then
  Return SetError(105); Download failed
$ServerTimeStamp = IniRead($INI, "SoftwareUpdate", "Timestamp", "0")
$ServerVersion = IniRead($INI, "SoftwareUpdate", "Version", "")
If $ServerTimeStamp = "0" Then Return SetError(109)
$LocalVersion = FileGetVersion($EXE, "FileVersion")
If String($LocalVersion) = String($ServerVersion) Then Return 0 ; no new version
If InetGet($RemoteServerURL & $EXE, $EXE & ".new", 1) = 0 Then
  FileDelete($EXE & ".new")
  Return SetError(110); Download failed
$rc1 = FileMove($EXE, $EXE & ".old", 1)
$rc2 = FileMove($EXE & ".new", $EXE, 1)
Run(@ComSpec & " /c PING -n 3 && DEL  """ & $EXE & ".old""", "", @SW_HIDE)
Exit Run($EXE & " " & $CmdLineRaw)
EndFunc   ;==>_SoftwareUpdate

Don't forget to copy the two files to the HTTP server after compile.


App: Au3toCmd              UDF: _SingleScript()                             

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By TheDcoder
      Hi, I have a 2D array with 2 columns, the 1st column contains a "version string" and the 2nd column contains a generic string. I want to sort it in the descending order so the latest version comes first.
      #include <Array.au3> Local $aVersionsAndReleases[4][2] = [["", "Release #1"], ["", "Release #3"], ["", "Release #4"], ["", "Release #2"]] _ArraySort($aVersionsAndReleases, 1) ConsoleWrite(_ArrayToString($aVersionsAndReleases, ' - ')) _ArrayDisplay($aVersionsAndReleases) Unfortunately, _ArraySort isn't working here . This is the output generated by the script: - Release #4 - Release #3 - Release #1 - Release #2 The expected result should be: - Release #4 - Release #3 - Release #2 - Release #1 I am looking to develop an function which does this... but I don't know where to start . Can someone help me get started? Thanks in Advance!
      - TD.
    • By ur
      In the present product I have version in the About section as  4 section one like (
      And the version in other products I have version number like (97.000.2456 , 10.000.2345)
      Is there any UDF or function to convert 4 digit format to 3 digit one.?
      I need that for version comparison of different products.
    • 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)
      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:(\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 a.exe b.exe Faint-v4.0.0.exe <-- 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?
    • By ur
      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??

    • By IT_9600
      how can I read the complete Version and Build-Numer for Windows 10?
      If I execute "winver.exe" in windows command-line I get the Build "10586.420".
      When I run "@OSBuild" in autoit I get "10586" and when I run "FileGetVersion(@SystemDir & "\WinVer.exe"" I get "10.0.10586.0".
      How can I get the rest of the number 420?
      Thanks for help!
  • Create New...