Jump to content

Who wants to write an AutoIt Updater?


Jon
 Share

Recommended Posts

I actually started doing something with this myself, I know we don't need 10 people all doing a script for this, but I know what I want, and it will be a learning experience for me. I never had a use for InetGet before, and now I do. So even if it's not used, at least I'll learn something, and I'll probably use my own version anyway. :idiot:

I might do comments after, but here's what I have so far:

*Edit: I have a bad habit of putting semicolons at the end of all my lines. For this script I'll have to remember to keep leaving them out.

New code

Edited by Saunders
Link to comment
Share on other sites

  • Replies 112
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I actually started doing something with this myself, I know we don't need 10 people all doing a script for this, but I know what I want, and it will be a learning experience for me. I never had a use for InetGet before, and now I do. So even if it's not used, at least I'll learn something, and I'll probably use my own version anyway. :D

I might do comments after, but here's what I have so far:

*Edit: I have a bad habit of putting semicolons at the end of all my lines. For this script I'll have to remember to keep leaving them out.

#NoTrayIcon
#include <GUIConstants.au3>

Global Const $s_Title = 'AutoIt3 Update Utility'
Global Const $s_DatFile = 'http://www.autoitscript.com/autoit3/update.dat'
Global Const $s_DatFile_Local = @ScriptDir & '\update.dat'
Dim $i_DatFileLoaded = 0

$s_Path = IniRead(@ScriptDir & '\Settings.ini', 'Settings', 'Au3Loc', -1)

If $s_Path = -1 Then
    MsgBox(64, $s_Title, 'Welcome to the AutoIt3 updating utility.' & @LF &_
                         'First let''s select the folder where you installed AutoIt3.')
    
    Dim $s_DefaultPath = RegRead('HKLM\Software\AutoIt v3\AutoIt', 'InstallDir')
    Dim $s_Path = FileSelectFolder('Select AutoIt v3 Installation Path', "", 0, $s_DefaultPath)

; add FileExists to see if the AutoIt exe is in this folder
    
    If @error Then
        MsgBox(64, $s_Title, 'You pressed cancel on the preceding dialog.' & @LF &_
                             'This utility will now close.')
        Exit(1)
    Else
        MsgBox(64, $s_Title, 'The location of your AutoIt3 installation folder will now be saved.' & @LF &_
                             'To change this location, choose "Options > Change AutoIt Install Location" from the main menu.')
        IniWrite(@ScriptDir & '\Settings.ini', 'Settings', 'Au3Loc', $s_Path)
    EndIf
EndIf

$s_CurrVer = FileGetVersion($s_Path & "\AutoIt3.exe")

GuiCreate($s_Title, 350, 220)

$me_Main = GuiCtrlCreateMenu('&Options')
$me_ChangeLoc = GuiCtrlCreateMenuItem('&Change AutoIt Install Location', $me_Main)

$me_Help = GuiCtrlCreateMenu('&Help')
$me_GoToSite = GuiCtrlCreateMenuItem('&Visit the AutoIt3 Website', $me_Help)
$me_AboutAu3 = GuiCtrlCreateMenuItem('&About AutoIt3', $me_Help)
$me_AboutAu3Upd = GuiCtrlCreateMenuItem('About AutoIt3 &Update Utility', $me_Help)
GuiCtrlCreateGroup('Current Installation Details', 5, 5, 340, 60)
GuiCtrlCreateLabel('Install Path: ' & $s_Path, 15, 25, 300, 15)
GuiCtrlCreateLabel('AutoIt3.exe Version: ' & $s_CurrVer, 15, 40, 300, 15)

GuiCtrlCreateGroup('Latest AutoIt3 Versions', 5, 75, 340, 60)
$lb_ReleaseVer = GuiCtrlCreateLabel('Public Release Version: Loading...', 15, 95, 300, 15)
$lb_BetaVer = GuiCtrlCreateLabel('Beta Version: Loading...', 15, 110, 300, 15)

$bt_ReleaseDl = GuiCtrlCreateButton('Download Public Release', 5, 150, 165, 30)
$bt_BetaDl = GuiCtrlCreateButton('Download Beta', 175, 150, 165, 30)
$lb_ReleaseSize = GuiCtrlCreateLabel('Size: Loading...', 5, 185, 165, 15, $SS_CENTER)
$lb_BetaSize = GuiCtrlCreateLabel('Size: Loading...', 175, 185, 165, 15, $SS_CENTER)

GuiSetState()

InetGet($s_DatFile, $s_DatFile_Local, 1, 1)

While 1
    $msg = GUIGetMsg()

    If Not @InetGetActive And Not $i_DatFileLoaded Then
        If @InetGetBytesRead = -1 Then
            MsgBox(16, 'Error', 'Error connecting to site.' & @LF &_
                                'Check to ensure your internet connection is working properly.')
            Exit(2)
        Else
            $s_ReleaseVer = IniRead($s_DatFile_Local, 'AutoIt', 'version', 'Error reading file')
            $s_ReleaseFile = IniRead($s_DatFile_Local, 'AutoIt', 'setup', '')
            $i_ReleaseSize = Round(InetGetSize($s_ReleaseFile) / 1024, 2)

            $s_BetaVer = IniRead($s_DatFile_Local, 'AutoItBeta', 'version', 'Error reading file')
            $s_BetaFile = IniRead($s_DatFile_Local, 'AutoItBeta', 'setup', '')
            $i_BetaSize = Round(InetGetSize($s_BetaFile) / 1024, 2)

            GuiCtrlSetData($lb_ReleaseVer, 'Public Release Version: ' & $s_ReleaseVer)
            GuiCtrlSetData($lb_BetaVer, 'Beta Version: ' & $s_BetaVer)

            GuiCtrlSetData($lb_ReleaseSize, 'Size: ' & $i_ReleaseSize & 'KB')
            GuiCtrlSetData($lb_BetaSize, 'Size: ' & $i_BetaSize & 'KB')
            $i_DatFileLoaded = 1
        EndIf
    EndIf

    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
Wend

<{POST_SNAPBACK}>

:lol: cool Script good job :idiot:
Link to comment
Share on other sites

Good start - I prefer the second one because the GUI looks a bit more professional and also there isn't a pause while it's doing the download, you can see something's going on. One question - can I ask why boths of these prompt for the AutoIt install directory? Can't they just read it from the registry and only prompt if that doesn't exist?

Link to comment
Share on other sites

Oh, and another thought just sprung to mind... These are only designed for downloading the new version. Do we want to download and then auto-install it to (or at least prompt the user with this as an option)? Does the installer support a /silent or something option to make this easier?

Just a couple of thoughts of things that could be added.

Link to comment
Share on other sites

  • Administrators

One thing I would suggest is that you should use the @TempDir any temp files (I think one of the scripts downloads the update.dat into the script directory, which will be program files so not always writable depending on the user).

Nice start though :idiot:

Link to comment
Share on other sites

If somebody does decide to script the installation, too, please, for the sake of people's sanity, DO NOT just blindly run it with the silent option. It overwrites settings by default (The last time I checked). If somebody caused my settings to be overwritten by defaults, well, lets just say I'd be having some fun with a pair of pliers and a blowtorch (Thats an homage to a movie, by the way).

Seriously, though, the silent method does use the overwrite method so all registry changes are lost.

Link to comment
Share on other sites

  • Administrators

If somebody does decide to script the installation, too, please, for the sake of people's sanity, DO NOT just blindly run it with the silent option.  It overwrites settings by default (The last time I checked).  If somebody caused my settings to be overwritten by defaults, well, lets just say I'd be having some fun with a pair of pliers and a blowtorch (Thats an homage to a movie, by the way).

Seriously, though, the silent method does use the overwrite method so all registry changes are lost.

Yeah, this is more of a GUI exercise so I would like it to just run the installer in normal mode rather than any silent stuff.

To save an initial filesize query i've added the filesize (bytes) to the dat file. As the docs state sometimes the filesize function can be blocked by IE versions/proxies/firewalls/whatever so be careful.

[AutoIt]
version=3.0.102.0
index=http://www.autoitscript.com/autoit3/downloads.php
setup=http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe
filesize=1035405

[AutoItBeta]
version=3.0.103.156
index=http://www.autoitscript.com/autoit3/files/beta/autoit/
setup=http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.0.103.exe
filesize=14779700

I think the gui should also show the current installed version number too.

Oh, one more thing, when going to the download page you shoudl call the default browser rather than assuming iexplorer. :idiot:

Link to comment
Share on other sites

One question - can I ask why boths of these prompt for the AutoIt install directory? Can't they just read it from the registry and only prompt if that doesn't exist?

<{POST_SNAPBACK}>

Mine actually checks the registry first, and uses that as the default directory in the folder select. Personally, I have it do a prompt in case of registry problems. Perhaps it wasn't installed using the installer, etc.

One thing I would suggest is that you should use the @TempDir any temp files (I think one of the scripts downloads the update.dat into the script directory, which will be program files so not always writable depending on the user).

<{POST_SNAPBACK}>

Good idea. I actually didn't realize that folder was sometimes not writeable.

To save an initial filesize query i've added the filesize (bytes) to the dat file.  As the docs state sometimes the filesize function can be blocked by IE versions/proxies/firewalls/whatever so be careful.

[...]

I think the gui should also show the current installed version number too.

Oh, one more thing, when going to the download page you shoudl call the default browser rather than assuming iexplorer.  :idiot:

<{POST_SNAPBACK}>

All good points. I didn't like having to do InetGetSize. Showing current version is definitely a good idea. And personally when it launched the download page I was going to use @ComSpec & ' /c start'.

*Edit: I just realized a bit of a problem... since when was the Beta over 14mb? :D

Edited by Saunders
Link to comment
Share on other sites

Is it possible to add some kind of "what's new" function to the script? Maybe add the changelog up until the version number of the installed version?

For example: Installed version might be 3.0.101, so add a changelog from latest beta "down to" 3.0.101

That would probably require a new type of changelog, including all the beta versions?

I'm not sure if something like that is possible, but I would like it!

Thanks,

Richard

Link to comment
Share on other sites

  • Administrators

Quick question: Is there a way to cancel an InetGet? I wanted to add a cancel button to my download dialog, but I can't figure out a way to make a download stop without Exiting the entire script.

Not at the moment.
Link to comment
Share on other sites

Okay then. By the way, you still haven't fixed the filesize for the beta in the update.dat :idiot:

According to my script here, the download is finished at 10% (1480.47 KB of 14433.3 KB) :D

So here's what I've got so far. I just have to code the menu items (to be honest, I kinda forgot I put them there until just now). It's barely commented, but I'm not going to bother writing up a bunch of comments if someone else is just going to make a better version.

I'm attaching it, cus it's 236 lines, and I hate when people put huge amounts of code in a post.

*New Version Below*

Edited by Saunders
Link to comment
Share on other sites

If somebody does decide to script the installation, too, please, for the sake of people's sanity, DO NOT just blindly run it with the silent option.  It overwrites settings by default (The last time I checked).  If somebody caused my settings to be overwritten by defaults, well, lets just say I'd be having some fun with a pair of pliers and a blowtorch (Thats an homage to a movie, by the way).

Seriously, though, the silent method does use the overwrite method so all registry changes are lost.

<{POST_SNAPBACK}>

OK, fairy point - and I didn't know that. I was only suggesting perhaps to give the user the OPTION to auto-install after downloading - I know I'm lazy and would prefer it this way :idiot: Edited by Chris_1013
Link to comment
Share on other sites

Got a new version here. At the moment I think I'm done, aside from comments, which I'm really not very good at, but I feel like I'm forgetting something... I dunno.

I've already used it once (updated from beta .156 to .160) and it seems to work pretty good.

Oh that's right.. I was going to add an autoinstall option, using the /silent switch mentioned earlier...

Well, okay, anyway here it is so far, and again it's an attachment (315 lines now).

Also, it #include's the UDF I posted here.

Hope you enjoy it!

Stuff I'd like to add:

- Add auto install option (/silent)

- Command line switches for more automation

Any other ideas?

*Edit: And just out of curiousity, is anyone else working on this? I'd like to see how other people's work is coming along.

*Edit 2: Newer version beyond...

Edited by Saunders
Link to comment
Share on other sites

  • Administrators

Got a new version here. At the moment I think I'm done, aside from comments, which I'm really not very good at, but I feel like I'm forgetting something... I dunno.

I've already used it once (updated from beta .156 to .160) and it seems to work pretty good.

Oh that's right.. I was going to add an autoinstall option, using the /silent switch mentioned earlier...

Well, okay, anyway here it is so far, and again it's an attachment (315 lines now).

Also, it #include's the UDF I posted here.

Hope you enjoy it!

Stuff I'd like to add:

- Add auto install option (/silent)

- Command line switches for more automation

Any other ideas?

*Edit: And just out of curiousity, is anyone else working on this? I'd like to see how other people's work is coming along.

Nice. :D

A few comments:

Your registry check for the installation directory has a typo (around line 21) - which is why it keeps asking me for my install dir!

Can you round the KB shown to 1011 KB rather than 1011.14 KB.

When you are downloading the file and you are saving to a long path (C:\Documents and Settings\User\Desktop) the path name is half missing during the download.

Maybe have some sort of "older" or "newer" tag next to the versions - some people have odd ideas about reading and comparing version strings :lol:

I think you should delete the temporary file rather than using it for next time - this script will always be run from a shortcut/full install so if it can't read the registry key for the installation it should say so rather than forcing the user to select a directory. Just say "installation not found" and then just act as a simple file downloader.

Not sure the file should be downloaded into the install directory by default. I'd prefer somewhere writable and normal like the Desktop or something.

Phew

:idiot:

Link to comment
Share on other sites

Just a quick note to say that it looks very professional - well done.

A minor issue:

After download is complete - I get the option to 'Open'

This starts the install process - I chose to overwrite in order to preserve my settings - it cannot complete this because AutoUpdateIt is using the exe.

AutoUpdateIt.exe needs to exit first.

Link to comment
Share on other sites

Your registry check for the installation directory has a typo (around line 21) - which is why it keeps asking me for my install dir!

Yeah, whoops on my part, I was forcing it to not find the reg. value so I could test the folder select dialog.

Can you round the KB shown to 1011 KB rather than 1011.14 KB.

Sure thing

When you are downloading the file and you are saving to a long path (C:\Documents and Settings\User\Desktop) the path name is half missing during the download.

Yeah, I wasn't sure about how to go about shortening that. I'm thinking I'll just go with having it snip out the middle of the path string if it's over a certain amount of characters.

*Edit: Actually it looks like we were talking about different things. In your example, when the destination gets too long it's wrapping the text in the Label. I've fixed that now, but I'm also thinking of shortening extra long paths to fit in the label. Something like taking "C:\Documents and Settings\User\Desktop" and making it "C:\Documents an...er\Desktop"

Maybe have some sort of "older" or "newer" tag next to the versions - some people have odd ideas about reading and comparing version strings :idiot:

Actually, using the CompareVersions function, it does do something like this, but only for newer versions. (ie: if the online version is newer, where it says the version number it has *Newer* next to it) I can easily add an 'Older' and maybe 'Current' string to tack onto the end of the strings.

I think you should delete the temporary file rather than using it for next time - this script will always be run from a shortcut/full install so if it can't read the registry key for the installation it should say so rather than forcing the user to select a directory.  Just say "installation not found" and then just act as a simple file downloader.

Okay, that makes sense. So even if it can't find the existing AutoIt you'd like it to still download the file.

Not sure the file should be downloaded into the install directory by default.  I'd prefer somewhere writable and normal like the Desktop or something.

Okey doke. Desktop sounds good.

Just a quick note to say that it looks very professional - well done.

Thanks! :D

After download is complete - I get the option to 'Open'

This starts the install process - I chose to overwrite in order to preserve my settings - it cannot complete this because AutoUpdateIt is using the exe.

As I see it, this should only be a problem if you run the .au3, because it will run AutoIt3.exe to make it work. If AutoUpdateIt were compiled, this wouldn't be a problem... perhaps we could include the au3 and an exe? Or would it be better if I just had it exit the whole application upon clicking the Open button?

Thanks for the comments guys, I'll be sure to try and get this working as quick as possible.

*Edit: How does this /silent install option work? I tried just running autoit-v3-setup.exe /silent but it acts like normal.

Edited by Saunders
Link to comment
Share on other sites

All suggestions taken into consideration:

- No more saving install location to .ini file. Loaded from the registry only, and if not found assumes that AutoIt is not installed.

- Filesize is rounded to an integer.

- Long paths are clipped short. Not sure how much I like it at the moment.

- (Current), (Old), *New*, appear next to file versions.

- When clicking Open, Open Folder, or Close, the program completely exits.

- When downloading, the file is first put in the @TempDir, and then moved to the user specified location when the download is done. Also, if the download is cancelled before completion, the file is deleted. I used the @TempDir method because now if you "overwrite" a file, then it doesn't truly overwrite until the download is complete.

- Added a close button to the About window.

And I think that's it. No command line stuff yet. I don't think I'll bother until I get the "silent install" stuff people were talking about figured out.

Updated _CompareVersions as well.

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