Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 02:28

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Check for program updates @ startup

Discussion on Check for program updates @ startup within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
badguy4you's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 477
Received Thanks: 178
Check for program updates @ startup

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
badguy4you is offline  
Old 07/21/2012, 10:12   #2
 
elite*gold: 300
Join Date: Mar 2010
Posts: 2,681
Received Thanks: 3,471
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)
Andrew™ is offline  
Thanks
4 Users
Old 07/21/2012, 10:34   #3
 
qickly's Avatar
 
elite*gold: 0
Join Date: Apr 2011
Posts: 351
Received Thanks: 57
But remember that you can easily bypass that force update, you should use a kind of crypter...
qickly is offline  
Old 07/23/2012, 00:21   #4
 
kissein's Avatar
 
elite*gold: 0
Join Date: Sep 2005
Posts: 426
Received Thanks: 87
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
kissein is offline  
Old 07/28/2012, 14:04   #5


 
Whoknowsit's Avatar
 
elite*gold: 146
Join Date: May 2009
Posts: 3,764
Received Thanks: 6,973
Depending on the used language, you could use the Clickonce-Feature of Visual Studio. The easiest and (for me) best way.
Whoknowsit is offline  
Old 08/01/2012, 09:13   #6
 
Der Anbieter's Avatar
 
elite*gold: 50
Join Date: Sep 2010
Posts: 846
Received Thanks: 223
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
Der Anbieter is offline  
Old 08/01/2012, 13:38   #7
 
kissein's Avatar
 
elite*gold: 0
Join Date: Sep 2005
Posts: 426
Received Thanks: 87
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?
kissein is offline  
Old 08/03/2012, 17:06   #8
 
Der Anbieter's Avatar
 
elite*gold: 50
Join Date: Sep 2010
Posts: 846
Received Thanks: 223
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

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
Der Anbieter is offline  
Old 08/03/2012, 17:41   #9
 
kissein's Avatar
 
elite*gold: 0
Join Date: Sep 2005
Posts: 426
Received Thanks: 87
Quote:
Originally Posted by Devilbyte View Post
it's my version and it works good

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
kissein is offline  
Old 08/03/2012, 23:25   #10
 
Der Anbieter's Avatar
 
elite*gold: 50
Join Date: Sep 2010
Posts: 846
Received Thanks: 223
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
Der Anbieter is offline  
Old 08/04/2012, 20:43   #11
 
badguy4you's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 477
Received Thanks: 178
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 ?!
badguy4you is offline  
Old 08/07/2012, 17:28   #12
 
tooti's Avatar
 
elite*gold: 18
Join Date: Jun 2009
Posts: 1,089
Received Thanks: 301
Why you dont use this?
tooti is offline  
Old 08/08/2012, 10:34   #13
 
Der Anbieter's Avatar
 
elite*gold: 50
Join Date: Sep 2010
Posts: 846
Received Thanks: 223
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
Der Anbieter is offline  
Old 08/08/2012, 10:37   #14


 
Whoknowsit's Avatar
 
elite*gold: 146
Join Date: May 2009
Posts: 3,764
Received Thanks: 6,973
Whoknowsit is offline  
Reply


Similar Threads Similar Threads
Zygor Guide Updates and Updates
02/09/2018 - WoW Guides & Templates - 5 Replies
Hy guys! Zygor Guides 3.0.1692: Last Updated On: January 14th, 2011 Horde Guides Change Log: (Northrend 70-72) - Step 103 - Guide now instructs players to deliver the Orphaned Mammoth Calf and tracks its completion before telling them to turn in the quest "Khu-nok Will Know". This was added for clarification purposes. (Northrend 70-71) - Moved the ding steps for 71
Combat Arms Mod [Wöchentliche Updates / Weekly Updates]
03/23/2011 - Combat Arms - 4 Replies
Combat Arms Mod _________________________________________________ _______________ Deutsch: Hier sind alle Mods in Übersicht (Konas sind nicht dabei). Englisch: Here are all Mods
Tq program works! check
05/11/2006 - CO2 Exploits, Hacks & Tools - 23 Replies
text2schild.php?smilienummer=1&text= and 1 karma's ARE Welcome' border='0' alt=' and 1 karma's ARE Welcome' />



All times are GMT +2. The time now is 02:28.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.