Results 1 to 8 of 8

Thread: How to make an updater?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Location
    United States
    Posts
    29

    Unhappy How to make an updater?

    Ok, So I am trying to make an updater for one of my applications but i need to know how to figure out if the updated file exists. I have this but it doesnt work... i was wondering if anyone could tell me how to do this. I would be very greatful. Thankyou...

    Current Code:
    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If My.Computer.FileSystem.FileExists("http://www.domain.com/file.exe") Then
                My.Computer.Network.DownloadFile("http://www.domain.com/file.exe", "C:/file.exe")
                MsgBox("YES")
            Else
                MsgBox("NO!")
            End If
        End Sub
    End Class

    Thank you for ANY help.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Location
    United States
    Posts
    29

    Re: How to make an updater?

    I think i found a way to do this...
    i just would have to have a separate file on the website with the version in it.


    Code:
            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            My.Computer.Network.DownloadFile("http://host.com/version.txt", My.Computer.FileSystem.SpecialDirectories.Temp & "\version.txt")
    
            Dim a As New System.IO.StreamReader(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.txt")
            Dim b As String = a.ReadToEnd
            a.Close()
    
            If Not b = "V2" Then
                MsgBox("NO UPDATE!")
            Else
                If MsgBox("Update Found. Would you like to update now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                    My.Computer.Network.DownloadFile("http://host.com/file.exe", My.Computer.FileSystem.SpecialDirectories.Temp & "\file.exe")
                    MsgBox("Updated!")
                End If
            End If
        End Sub
    I still need to test this but unfortunatly i am not near my computer that i can do that on. I will let you know if it works.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Location
    United States
    Posts
    29

    Re: How to make an updater?

    I was able to go home and test it and i got it to work with this code...
    This will update an Application of mine when it finds that there IS an update it will navigate to the page on my site where you can download it. And for some strang reason my site wouldnt let me use text files so i had to store the text in a JPG. But you should be able to use Text files... it is still wierd though... Anyhoo.... here is the working code for anyone who cares.

    Code:
    Private Sub CheckForUpdatesNowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckForUpdatesNowToolStripMenuItem.Click
            If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg") Then
                My.Computer.FileSystem.DeleteFile(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg")
            End If
    
            My.Computer.Network.DownloadFile("http://thefiscster510.hostzi.com/data/apps/phpdata/version.jpg", My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg")
    
            Dim a As New System.IO.StreamReader(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg")
            Dim b As String = a.ReadToEnd
            a.Close()
    
            If Not b = "V2" Then
                MsgBox("You are currently Up-To-Date.")
            Else
                If MsgBox("Update Found. Would you like to update now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                    Process.Start("http://thefiscster510.hostzi.com/data/download.php?D_FILE1=Guest&D_FILE2=wamp.zip")
                End If
            End If
            My.Computer.FileSystem.DeleteFile(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg")
        End Sub
    Hope this somehow helped.

  4. #4
    Addicted Member
    Join Date
    Oct 2009
    Posts
    212

    Re: How to make an updater?

    I've completed this task using this logic.
    Get current assembly.exe version number.
    Check website xml file for current version number
    If needed download the new version
    Save the file as assemblyname.updater.exe
    Launch the assemblyname.updater.exe file and exit the assemblyname.exe
    On assembly start up check to see if the assembly is "assemblyname.updater.exe"
    If it is delete assemblyname.exe, and copy the updater file to assemblyname.exe
    Start assemblyname.exe and delete assemblyname.updater.exe if it exists.

    I know there has got to be an easier way....
    Have you tried Google?

  5. #5
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: How to make an updater?

    This is how I do it:

    1) Download text-file from sever which contains a number (e.g. 1.0.0.1)
    2) Compare the number with assembly-number
    3) If number of server-file higher then Close mainApp and start Update.exe (the update.exe is in the app.path)
    4) Update.exe >> Download new .exe and replace the old one.
    5) Start the new .exe (mainApp) and close updater.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Location
    United States
    Posts
    29

    Re: How to make an updater?

    That is what i did... i just had to use a JPEG cause my host doesnt like txt files.

  7. #7
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: How to make an updater?

    You've got a weird host...


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Location
    United States
    Posts
    29

    Re: How to make an updater?

    haha yes i do, but its free so I'm not complaining.
    If I fail... You can prolly go anywhere else and get teh right answer

    Please Visit my site:
    http://www.fiscalleti.com/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width