Check for program updates @ startup

07/21/2012 02:34 badguy4you#1
I want to make my program check if there is a new version on the program site and if so downloads it and did not start if it is not latest version

So in WyBuild can i make it Force update my program


Please tell me ur opinions BUT i dont wanna the program to start at all if it were not latest version
07/21/2012 10:12 Andrew™#2
Simple:
Code:
Public Class Form1 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
CheckForUpdates() 
End Sub 

Public Sub CheckForUpdates() 
Dim file As String = Application.StartupPath & "/version.txt" 
Dim MyVer As String = My.Application.Info.Version.ToString 

If My.Computer.FileSystem.FileExists(file) Then 
My.Computer.FileSystem.DeleteFile(file) 
End If 

My.Computer.Network.DownloadFile("http://your.url/version.txt", file) 
Dim LastVer As String = My.Computer.FileSystem.ReadAllText(file) 

If Not MyVer = LastVer Then 
MsgBox("Update Available")
'My.Computer.Network.DownloadFile("http://your.url/program.exe", "") 
Me.Close()
Else 
MsgBox("Program is up to date")
End If 
End Sub 

End Class
Code of version.txt:
Code:
1.0.0.0
(^^example)
07/21/2012 10:34 qickly#3
But remember that you can easily bypass that force update, you should use a kind of crypter...
07/23/2012 00:21 kissein#4
If you want to know the version of your own assembly try something like:

Code:
using System.Reflection;

Assembly.GetAssembly(typeof(Form1)).GetName().Version.ToString();
Where Form1 is a class defined in the assembly you want to know the version
of.

or

Code:
Assembly.GetExecutingAssembly().GetName().Version.ToString()
rest should be plain easy to implement
07/28/2012 14:04 Whoknowsit#5
Depending on the used language, you could use the Clickonce-Feature of Visual Studio. The easiest and (for me) best way.
08/01/2012 09:13 Der Anbieter#6
This is my Code for Visual Basics 2010:

make a new project and add this code:
Code:
Public Class myupdater

    Dim Web As New System.Net.WebClient
    Dim EnteredSerial As String
    Dim newVersion As String = ""
    Dim Retry As Integer


    

    Private Sub myupdater_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            Try


                Dim myVersion As String
                myVersion = My.Computer.FileSystem.ReadAllText("C:\mypath\version.txt")
                ''

                newVersion = Web.DownloadString("http://my.url/version.txt")
                If Not newVersion.Contains(myVersion) Then
                    Label1.ForeColor = Color.Red
                    Label1.Text = "Updating."


                    If My.Computer.FileSystem.DirectoryExists("C:\mypath\") Then
                        If My.Computer.FileSystem.FileExists("C:\mypath\my_Tool.exe") Then
                            IO.File.Delete("C:\mypath\my_Tool.exe")

                            My.Computer.Network.DownloadFile("http://my.url/my_Tool.exe", "C:\mypath\my_Tool.exe")
                            'System.Diagnostics.Process.Start("C:\mypath\my_Tool.exe")
                        Else
                            My.Computer.Network.DownloadFile("http://my.url/my_Tool.exe", "C:\mypath\my_Tool.exe")
                            'System.Diagnostics.Process.Start("C:\mypath\my_Tool.exe")
                        End If

                        If My.Computer.FileSystem.FileExists("C:\mypath\version.txt") Then
                            IO.File.Delete("C:\mypath\version.txt")

                            My.Computer.Network.DownloadFile("http://my.url/version.txt", "C:\mypath\version.txt")
                            'System.Diagnostics.Process.Start("C:\mypath\my_Tool.exe")
                        Else
                            My.Computer.Network.DownloadFile("http://my.url/version.txt", "C:\mypath\version.txt")
                            'System.Diagnostics.Process.Start("C:\mypath\my_Tool.exe")
                        End If



                    Else
                        My.Computer.FileSystem.CreateDirectory("C:\mypath\")

                        My.Computer.Network.DownloadFile("http://my.url/my_Tool.exe", "C:\mypath\my_Tool.exe")
                        My.Computer.Network.DownloadFile("http://my.url/version.txt", "C:\mypath\version.txt")

                        'System.Diagnostics.Process.Start("C:\mypath\my_Tool.exe")
                    End If


                    System.Diagnostics.Process.Start("C:\mypath\my_Tool.exe")
                    Me.Close()
                Else
                    System.Diagnostics.Process.Start("C:\mypath\my_Tool.exe")
                    'newVersion.Show()
                    Me.Close()
                End If
            Catch Ex As Exception
                MsgBox("Ein Fehler ist aufgetreten:" & vbCrLf & Ex.Message)

            End Try
    End Sub
End Class
Then add this to your main programm:

Under your "Public Class"

Code:
Dim Web As New System.Net.WebClient
    Dim EnteredSerial As String
    Dim newVersion As String = ""
    Dim Retry As Integer
Into your Form1_load:

Code:
Try

                Dim myVersion As String
                myVersion = My.Computer.FileSystem.ReadAllText("C:\mypath\version.txt")
                ''

                newVersion = Web.DownloadString("http://my.url/version.txt")
                If Not newVersion.Contains(myVersion) Then
                                msgBox("A newer Version is available, the Programm will close now.")
                                System.Diagnostics.Process.Start("C:\mypath\Updater.exe")
                                End
                End if
End Try
You just have to change the paths, names, etc.. to yours.
And you have to add a Label.

/done
08/01/2012 13:38 kissein#7
Quote:
myVersion = My.Computer.FileSystem.ReadAllText("C:\mypath\vers ion.txt")
Thats really a bad idea to depend on an external file, which u need to know the filepath.
Update method is bad too, why do u want to update your whole application instead of just the part who really needs the update ?

Is this really the best way in VB.NET?
08/03/2012 17:06 Der Anbieter#8
Quote:
Originally Posted by kissein View Post
Thats really a bad idea to depend on an external file, which u need to know the filepath.
Update method is bad too, why do u want to update your whole application instead of just the part who really needs the update ?

Is this really the best way in VB.NET?
it's my version and it works good :o

but you could also check if it is existing, if it is deleted then the programm should tell the message that the programm needs to be reinstalled boh1
08/03/2012 17:41 kissein#9
Quote:
Originally Posted by Devilbyte View Post
it's my version and it works good :o

but you could also check if it is existing, if it is deleted then the programm should tell the message that the programm needs to be reinstalled boh1
your app -> maybe 100kb - 1mb ?
sure lets reinstall the whole application.

someone else project -> maybe 100mb -> 10 gb?
wo00t? 1 patch and i need to download/reinstall 1gb+, naaah bullshitbingo software


a good developer tries to break his own product to see how good/bad the results are...
for yours, i dont even need to know the source/part of it, to break your whole application into pieces.

just try to improve;)
08/03/2012 23:25 Der Anbieter#10
Quote:
Originally Posted by kissein View Post
your app -> maybe 100kb - 1mb ?
sure lets reinstall the whole application.

someone else project -> maybe 100mb -> 10 gb?
wo00t? 1 patch and i need to download/reinstall 1gb+, naaah bullshitbingo software


a good developer tries to break his own product to see how good/bad the results are...
for yours, i dont even need to know the source/part of it, to break your whole application into pieces.

just try to improve;)
A 100mb/10gb project is most likely programmed in c++ or another language, and for this there is more than just one file.

When there are updates only a few parts will get updated, like 1-5mb ;)
08/04/2012 20:43 badguy4you#11
Quote:
Originally Posted by Devilbyte View Post
A 100mb/10gb project is most likely programmed in c++ or another language, and for this there is more than just one file.

When there are updates only a few parts will get updated, like 1-5mb ;)
And why not just use WyBuild ?!
08/07/2012 17:28 tooti#12
Why you dont use this? [Only registered and activated users can see links. Click Here To Register...]
08/08/2012 10:34 Der Anbieter#13
Quote:
Originally Posted by badguy4you View Post
And why not just use WyBuild ?!
This was just a code example how i do it, which was just for learning vb ;)
08/08/2012 10:37 Whoknowsit#14
[Only registered and activated users can see links. Click Here To Register...]