[VB.NET]Autoupdate

01/18/2013 16:29 BeginnerDO#1
Hey,

How to make it?

So far I have used method like this:
-I have published single exe file
-"Autoupdate" = read newest version number from .txt file from my webpage (weebly) and if version number isnt same as in the exe file then bot opens download link (weebly too).

Well thats a really simple way to do it but this time Id like to know how to it more "professionally" :D I have thought to publish a whole folder instead of 1 exe file and updater updates just the necessary files. (how to get those? how to update? how to everything?)

I have several plans for this:
-User settings wont change anymore while newer version comes
-The updater should delete earlier version and download newest to same folder (or replace earlier one). At the moment, as I wrote on the top of msg, I have to select the folder every time.

Stubid question: Is this possible? making a startup form which loads "main form" from webpage. User settings / rescoures / etc would also be saved to loading form (but sometimes I should update them too..)

To be honest I have any idea how to start with this.. I hope you have :)
01/18/2013 16:39 Kraizy​#2
- check if new version is available
- start updater.exe/bat/...
- delete old version (close old version before deleting it if necessary)
- download new version
- start new version
01/18/2013 17:02 BeginnerDO#3
Quote:
Originally Posted by Kraizy​ View Post
- check if new version is available
- start updater.exe/bat/...
- delete old version (close old version before deleting it if necessary)
- download new version
- start new version
-The first one is clear. I know how to check
-This is too. I just have to make the updater
-Well I have never before deleted file but with fast googling found [Only registered and activated users can see links. Click Here To Register...]. looks it could work.
-download, how? I have earlier made: process.start([Only registered and activated users can see links. Click Here To Register...]) and this is the way I dont want to do anymore :) and how to get the location where earlier one is saved? (so it should autosave it to the same place)
01/18/2013 17:05 Kraizy​#4
Quote:
Originally Posted by BeginnerDO View Post
download, how? I have earlier made: process.start([Only registered and activated users can see links. Click Here To Register...]) and this is the way I dont want to do anymore :)
WebClient.DownloadFile(Async)

Quote:
Originally Posted by BeginnerDO View Post
and how to get the location where earlier one is saved? (so it should autosave it to the same place)
Well, what about Dropbox? Just drag your new version in the same folder (and replace it with the old version), the download link would be the same everytime.

Edit: Sorry didn't understand your second question.

PHP Code:
Dim myPath As String Application.ExecutablePath 
You could just pass myPath as a startup parameter to your updater.exe.
01/18/2013 17:17 BeginnerDO#5
Quote:
Originally Posted by Kraizy​ View Post
WebClient.DownloadFile(Async)



Well, what about Dropbox? Just drag your new version in the same folder (and replace it with the old version), the download link would be the same everytime.

Edit: Sorry didn't understand your second question.

PHP Code:
Dim myPath As String Application.ExecutablePath 
You could just pass myPath as a startup parameter to your updater.exe.
Thanks a lot :)

I think I get now the idea. I'll try later this evening
01/22/2013 04:00 »jD«#6
I generally generate an exe on runtime and launch that, that way that exe has access to overwrite/remove/create an exe that has the same name as the main program!

-jD
06/11/2013 10:11 BeginnerDO#7
Code:
    Public Shared Sub poista(nimi As String)
        Dim FileToDelete As String
        FileToDelete = Application.ExecutablePath.ToString()
        
        If System.IO.File.Exists(FileToDelete) = True Then
            System.IO.File.Delete(FileToDelete) 
        Else
           '
        End If

    End Sub
I quess this requires running as admistator? cause it's giving error: Access to the path [path] is denied. So it there any other way to do that? Or can I somehow ask "run as admistator" only for this?

I am also really getting annoyed with this updating cause its working correctly... Say whats wrong :D

Code:
 Dim linkki As Uri 'Download link'
 Dim Uusitiedosto As String 'Name of the newest version'

Uusitiedosto = xml.<NewDataSet>.<WebUpdate>.<Nimi1>.Value.ToString()
linkki = New Uri(xml.<NewDataSet>.<WebUpdate>.<DownloadLink>.Value)
            
            Try
                poista(tiedosto) 'this is above and gives the error'
            Catch ex As Exception
                MsgBox("Earlier version of cannot be deleted." & vbNewLine & vbNewLine & ex.ToString())
            End Try

            lataa(linkki, Uusitiedosto) 'downloads newest version with webclient.downloadFileAsync'

            MsgBox("Bot should be updated now :)" & vbNewLine & vbNewLine & "Restarting...") 'lets say this is MsgBoxA'

            Process.Start(Uusitiedosto) 'Another problem here'
            Form1.Close()
how can I make application wait that download is 100% ready? Now if I close MsgBoxA just after it popped up, process.start() doesnt work - it starts earlier version again (the same as application.restart() ). If I wait until the download is 100% ready and close the MsgBoxA after it then everything is working.
06/11/2013 13:45 YatoDev#8
Quote:
Originally Posted by »jD« View Post
I generally generate an exe on runtime and launch that, that way that exe has access to overwrite/remove/create an exe that has the same name as the main program!

-jD
hoe do you create a .exe in runtime ?
Your coding C# right ? :D

Can you give me a little example ?

hmm Thread a little bit to old ^^
06/11/2013 14:35 »Barney«#9
Quote:
Originally Posted by »FlutterShy™ View Post
hoe do you create a .exe in runtime ?
Your coding C# right ? :D

Can you give me a little example ?

hmm Thread a little bit to old ^^
He saves it into the global::Properties.Resources class, and creates the executable using a FileStream.
06/11/2013 18:31 YatoDev#10
Quote:
Originally Posted by chichi011 View Post
He saves it into the global::Properties.Resources class, and creates the executable using a FileStream.
ahh i thought he creates a .net exe in runtime and compile it and i thought wtf ^^
06/11/2013 20:41 »Barney«#11
Quote:
Originally Posted by »FlutterShy™ View Post
ahh i thought he creates a .net exe in runtime and compile it and i thought wtf ^^
Nah that's hard, not impossible but pretty hard. Add me in skype when you have time ;)
06/11/2013 22:27 'Heaven.#12
Use codedom...
06/12/2013 13:37 »Barney«#13
Quote:
Originally Posted by 'Heaven. View Post
Use codedom...
Much harder that way
06/12/2013 13:45 YatoDev#14
Quote:
Originally Posted by chichi011 View Post
Nah that's hard, not impossible but pretty hard. Add me in skype when you have time ;)
i dont want to do this :D
I can code myself :D
I only want to know how he's doing it