Jump to content

SelfUpdater


Go to solution Solved by Danyfirex,

Recommended Posts

Hey, I'm writing a updater to my script.

Basicly I want it to read from a webhost a versioncheck.ini (or .txt i dont care)

And from the version.ini (or .txt i dont care) in the scriptfolder)

And if the one on the webhost <> with the one in the script folder

then download and replace the new version of the .exe, changelog.txt, readme.txt and ressource folder.

Also it needs to write the new version into the version file in the folder.

This is what I have:

#NoTrayIcon
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <IE.au3>

;Updater
$VersionCheckNew = "http://www.mediafire.com/view/xxxxxxxxxx\versioncheck.ini"
$VersionCheckOld = IniRead("version.ini","Version","Version","NotFound")
$DownloadLink = "https://www.mediafire.com/folder/xxxxxxxx/FolderName"
$newVersion = "0.0.0"

$ini = InetGet($VersionCheckNew,@ScriptDir & '\versioncheck.ini') ; dl new ini

if $ini = 0 Then
    MsgBox(0,"Error","Something went wrong while checking for updates.")
Else
$newVersion = IniRead(@ScriptDir & "\versioncheck.ini","Version","Version","")
If $newVersion = $VersionCheckOld Then
Exit
Else
$MsgNewUpdate = MsgBox(4,"Update Avaible","There is a new update avaible. Do you wish to automaticly download it?")
if $MsgNewUpdate = 7 Then
    Filedelete(@ScriptDir & "\versioncheck.ini")
    Exit
Elseif $MsgNewUpdate = 6 Then
$DlHandleExe = InetGet($DownloadLink,@ScriptDir & "\MyScript.exe",1,1)

ProgressOn("", "", "", -1,-1,16)
$DownloadSize =InetGetSize($DownloadLink,1)
While not InetGetInfo($DlHandleExe, 2)
    $PercentDone = (InetGetInfo($DlHandleExe,0)/$DownloadSize)*100
    ProgressSet($PercentDone, $PercentDone & " percent")
    Sleep(1)

WEnd
ProgressSet(100,"Done","Update Completed")
Sleep(500)
ProgressOff()
IniWrite(@ScriptDir & "\version.ini","Version","Version",$newVersion)
InetClose($DlHandleExe)
MsgBox(-1,"Success","Download Complete!")
EndIf
EndIf
EndIf
FileDelete(@ScriptDir & "\versioncheck.ini")
Exit

I downloads with no problems etc.

but the content of the downloaded stuff looks like this:

MOWypcV.png

The original content of the file was:

P7fcewp.png

Is this because I'm doing it through mediafire? Or is it something with the code?

I am not intending to use mediafire, I just wanted to get the updater working asap.

I am waiting for a proper host to set my thingy up :)

I already read all the posts I could find on this, but it was old threads and I didn't understand them properly.

And I don't want to ressurect posts from the dead.

Cheers!

Edited by Srex
Link to comment
Share on other sites

I'm not soure but I think mediafire has not hotlink. You could find some txt uploader and read from it.

Saludos

Link to comment
Share on other sites

  • Solution

mediafire, mega. and other upload page use a method to avoid malware upload. (I think). Look at the medifire link. over the download botton right-click and click copy link direct address. that is the hotlink.

 

Saludos

Link to comment
Share on other sites

mediafire, mega. and other upload page use a method to avoid malware upload. (I think). Look at the medifire link. over the download botton right-click and click copy link direct address. that is the hotlink.

 

Saludos

 

Thanks dude! Fixed it <3

Edited by Srex
Link to comment
Share on other sites

If I wanted to not make it close the program if theres no update, or the user doesnt wish to update right now.

Could I put it inside a do loop? And that should work right?

Edited by Srex
Link to comment
Share on other sites

Only put as almost all software. when the app starts or put a button check for updates...

Saludos

Link to comment
Share on other sites

Only put as almost all software. when the app starts or put a button check for updates...

Saludos

 

Yeah I figured out how to do it correct!

The links changes when I upload a new version though, so it will download the old one still. Guess I'll need to purchase mediafire then -.-

Edit: Figured it out. Thanks!

Edited by Srex
Link to comment
Share on other sites

I'm not sure about that. for that I prefer a hotlink and raw data uploader.

Saludos

Link to comment
Share on other sites

There is a SelfUpdater UDF in my signature.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

There is a SelfUpdater UDF in my signature.

 

Yeah I already read it before posting this.

I already had it working, I was 95% it was bcus of mediafire, which it was

Edited by Srex
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...