Jump to content

Update and run program Func


Recommended Posts

Hi Brothers , Firstly Thank you all for helping me to learn Autoit Great language I learned alot from your examples .

Today I want to make Func searching for update from internet like this  :

Check Raw called "Version"

Download Raw Called "Lastest Download link"

Example :

$check = Read Raw from this link "https://raw.githubusercontent.com/abdulrahmanok/Version/master/version"

$download = Download file from this link"https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink"

and Copy download files To @scriptindir


I found Old posts tries to update but its very complicated.

Solved : Thanks To @Muhammad_Awais_Sharif

 

Edited by abdulrahmanok
Link to comment
Share on other sites

#include <Inet.au3>
#include <InetConstants.au3>

MsgBox(0,"version",_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version'))
Local $link = _INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink')

Local $hDownload = InetGet($link,"d:\filename",Default,$INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Do
    Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

 

Edited by Muhammad_Awais_Sharif
correct code :P
Link to comment
Share on other sites

Just now, Muhammad_Awais_Sharif said:
#include <Inet.au3>
#include <InetConstants.au3>

MsgBox(0,"version",_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version'))
Local $link _INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink')

Local $hDownload = InetGet($link,"c:\filename",Default,$INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Do
    Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

 

Ty For Fast response I will Try it now

Link to comment
Share on other sites

2 minutes ago, Muhammad_Awais_Sharif said:
#include <Inet.au3>
#include <InetConstants.au3>

MsgBox(0,"version",_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version'))
Local $link _INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink')

Local $hDownload = InetGet($link,"c:\filename",Default,$INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Do
    Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

 

No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.:
Local $link _INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink')
Local $link ^ ERROR

Link to comment
Share on other sites

#include <Inet.au3>
#include <InetConstants.au3>

MsgBox(0,"version",_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version'))
Local $link = _INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink')

Local $hDownload = InetGet($link,"d:\filename",Default,$INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Do
    $ArrayOFDownloadStatuts = InetGetInfo($hDownload)

    ConsoleWrite("currently downloaded " & Round($ArrayOFDownloadStatuts[0] / 2 ^ 10) & " KB" & @CRLF)
    ConsoleWrite("Total Size " & Round($ArrayOFDownloadStatuts[1] / 2 ^ 20, 2) & " MB" & @CRLF)

    Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

posted after testing :D:P 

Link to comment
Share on other sites

18 minutes ago, Muhammad_Awais_Sharif said:
#include <Inet.au3>
#include <InetConstants.au3>

MsgBox(0,"version",_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version'))
Local $link = _INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink')

Local $hDownload = InetGet($link,"d:\filename",Default,$INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Do
    $ArrayOFDownloadStatuts = InetGetInfo($hDownload)

    ConsoleWrite("currently downloaded " & Round($ArrayOFDownloadStatuts[0] / 2 ^ 10) & " KB" & @CRLF)
    ConsoleWrite("Total Size " & Round($ArrayOFDownloadStatuts[1] / 2 ^ 20, 2) & " MB" & @CRLF)

    Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

posted after testing :D:P 

Ty its working but look at full code :
 

#include <Inet.au3>
#include <InetConstants.au3>
#include <File.au3>
$updatecheck=_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version')
 $opennew = @ScriptDir & "/version.txt"
       Local $readOne = FileReadLine($opennew, 1)
    if $readOne = $updatecheck Then
        MsgBox(0,"Thank You" , " You Already Have lastest Update ")
        
        Else
    MsgBox(0,"OOPS" , "There IS Newer Version Avalible Please wait Until Downlad Finished")
checkupdate()
    EndIf

func checkupdate()
MsgBox(0,"version",_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version'))
Local $link = _INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink')

Local $hDownload = InetGet($link,"d:\filename.exe",Default,$INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Do
    $ArrayOFDownloadStatuts = InetGetInfo($hDownload)

    ConsoleWrite("currently downloaded " & Round($ArrayOFDownloadStatuts[0] / 2 ^ 10) & " KB" & @CRLF)
    ConsoleWrite("Total Size " & Round($ArrayOFDownloadStatuts[1] / 2 ^ 20, 2) & " MB" & @CRLF)
Run("filename.exe","d:\")
    Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
EndFunc

version.txt date is = 2.0

1- why Check doesn't work ?

2- Why it doesn't run file after download it ?

Link to comment
Share on other sites

3 minutes ago, Muhammad_Awais_Sharif said:

what do you mean check does not work ?
i think if you are asking about function then 

I mean Both Values are "2.0"

so it must show :

        MsgBox(0,"Thank You" , " You Already Have lastest Update ")

but it doesn't do this it still show that there is another newer update ...

And " Run" Is working now thanks

Edited by abdulrahmanok
Link to comment
Share on other sites

11 minutes ago, Muhammad_Awais_Sharif said:

what do you mean check does not work ?
i think if you are asking about function then 

  if $readOne = $updatecheck Then

may be because version are both same

2-because you are not giving right path  
 

Run("d:\filename.exe")

 

Thank You very much  I Solved This By Another Trick :
 

#include <Inet.au3>
#include <InetConstants.au3>

$asd=2.0
$updatecheck=_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version') 
    if $updatecheck <= $asd  Then
        MsgBox(0,"Thank You" , " You Already Have lastest Update ")
        
        Else
    MsgBox(0,"New IS COMING" , "There IS Newer Version Avalible Please wait Until Downlad Finished")
checkupdate()
    EndIf

func checkupdate()
MsgBox(0,"version",_INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/version'))
Local $link = _INetGetSource('https://raw.githubusercontent.com/abdulrahmanok/Version/master/LatestVersionLink')

Local $hDownload = InetGet($link,"d:\filename.exe",Default,$INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Do
    $ArrayOFDownloadStatuts = InetGetInfo($hDownload)

    ConsoleWrite("currently downloaded " & Round($ArrayOFDownloadStatuts[0] / 2 ^ 10) & " KB" & @CRLF)
    ConsoleWrite("Total Size " & Round($ArrayOFDownloadStatuts[1] / 2 ^ 20, 2) & " MB" & @CRLF)
Run("d:\filename.exe")   
 Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
EndFunc

Now I Don't  even need To "txt" File :)

 

Edited by abdulrahmanok
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...