Sign in to follow this  
Followers 0
hezi

read script version from my script

7 posts in this topic

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)

thanks.

Share this post


Link to post
Share on other sites



Use @AutoItVersion to get the version number.

Share this post


Link to post
Share on other sites

i will try that!!

thanks!

Share this post


Link to post
Share on other sites

Maybe this is a better solution

$version = FileGetVerion(@ScriptFullPath)

Because @AutoItVersion just displays the AutoItVersion (e.g. 3.3.8.1)


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


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.

Thanks!

Share this post


Link to post
Share on other sites

@hezi

Here is my solution for automatic update of my programs.

Perhaps you might do something like this.

; _Softwareupdate UDF include file      by Forumer100
; Example:
#cs
#AutoIt3Wrapper_Res_Fileversion=0.0.0.1
#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
Exit
; please copy %scriptfile%.exe and %scriptfile%.exe.ini to remote HTTP server after compile.
#ce
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)
EndIf
$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
Next
If @error Then Return SetError(100 + @error)
If InetGet($RemoteServerURL & $INI, $INI, 1) = 0 Then
  FileDelete($INI)
  Return SetError(105); Download failed
EndIf
$ServerTimeStamp = IniRead($INI, "SoftwareUpdate", "Timestamp", "0")
$ServerVersion = IniRead($INI, "SoftwareUpdate", "Version", "0.0.0.0")
FileDelete($INI)
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
EndIf
$rc1 = FileMove($EXE, $EXE & ".old", 1)
Sleep(500)
$rc2 = FileMove($EXE & ".new", $EXE, 1)
Sleep(500)
Run(@ComSpec & " /c PING -n 3 127.0.0.1 && 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.

Forumer100


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

wow thats great!!!

probably it will save me work...

Thanks

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
Sign in to follow this  
Followers 0

  • Similar Content

    • TheDcoder
      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] = [["0.2.8.9", "Release #1"], ["0.2.9.10", "Release #3"], ["0.2.9.11", "Release #4"], ["0.2.8.10", "Release #2"]] _ArraySort($aVersionsAndReleases, 1) ConsoleWrite(_ArrayToString($aVersionsAndReleases, ' - ')) _ArrayDisplay($aVersionsAndReleases) Unfortunately, _ArraySort isn't working here . This is the output generated by the script:
      0.2.9.11 - Release #4 0.2.9.10 - Release #3 0.2.8.9 - Release #1 0.2.8.10 - Release #2 The expected result should be:
      0.2.9.11 - Release #4 0.2.9.10 - Release #3 0.2.8.10 - Release #2 0.2.8.9 - 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.
    • ur
      By ur
      In the present product I have version in the About section as  4 section one like (10.00.00.2456)
      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.
    • Vivaed
      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
      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??

    • IT_9600
      By IT_9600
      Hello,
      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!