Jump to content

read script version from my script


hezi
 Share

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)

thanks.

Link to comment
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!

Link to comment
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

App: Au3toCmd              UDF: _SingleScript()                             

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

×
×
  • Create New...