[VB.NET]Auto Updater [Tutorial]

Posts 1–15 of 20 · Page 1 of 2
[VB.NET]Auto Updater [Tutorial]
I AM STEVE323!
DO NOT FLAME ME SAYING I LEECHED!
So you want your program to auto update. Well, here's the easy way I coded

First, make a new project. I suggest making a project first to test it out THEN adding it in to your program.

Now, add a WebBrowser. Make it Visible = false.

Next, add 2 Web Clients. To get a Web Client, first right click on one of your controls/blank space in the GENERAL SECTION(very important!) in the Toolbox and click Choose Items.
[img]http://j.image*********/0811/chooseitems.png[/img]


Then, scroll down to the bottom. Scroll up a TINY bit from there and you will see a checkbox marked WebClient.
[img]http://h.image*********/0453/webclient.png[/img]

Check it and click OK.

You should see something like this:
[img]http://h.image*********/0289/webclientinsection.png[/img]

Now click on that and drag in to your form 2 (2!) times. DO NOT RENAME THEM!


Now add two labels.

Arrange the labels like this:

Status: Checking for updates...

and put them anywhere on your form. I prefer the bottom but you can put them anywhere.


Now, add a button. This button can be anywhere and should say "Download Updates" noquotes. Make Enabled=False.


Now for the tricky part.

Double click your form. You should be in the Coding window. You should also be in Form1_Load.

Copy&paste this in: (exactly!)

Code:
WebClient1.DownloadFileAsync(New Uri("http://www.yourftpsite.com/version.txt"), "C:\version.txt")
What this will do is when you open the program it will download a small text file that has the version of your program. (ex. 1.0.0.0)
You must get a FTP server - online or offline - to use this correctly. I will use 110mb.com for this tutorial, it's easy to make an account and go into the FTP.

When you have created your account, go into the FTP. It should look like this on 110mb.

[img]http://j.image*********/0050/ftp.png[/img]

Click the small blue arrow. You should be in a site called "110MBPANEL". You've just gotten into the FTP server, good job.

Now click "New File". You will be presented with a textbox. Type in "version.txt" noquotes and press OK. You will be taken to a large text entry box. However, just type in "1.0.0.0" noquotes for the moment. We will change this later. Now click Save at the bottom and then Back at the bottom.

Go into the coding window of your project again. Add this code underneath Form1_Load.

Code:
Private Sub WebClient1_DownloadFileCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles WebClient1.DownloadFileCompleted
		Dim Read As String = My.Computer.FileSystem.ReadAllText("C:\version.txt")
		If Not Read = Application.ProductVersion Then
			'If it reads blank, then the internet connection is faulty.
			If Read = "" Then
				MsgBox("ERROR: Please check your internet connection or try later.", MsgBoxStyle.Critical, "ERROR")
			Else
				Label2.Text = "Update ready to download!"
				Button1.Enabled = True
				Label2.ForeColor = Color.Green
			End If
		Else
			Button1.Enabled = False
			Button1.Text = "Up to date."
			Label2.Text = "Up to date."
			Label2.ForeColor = Color.Green

		End If
	End Sub

Add underneath that:


Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		MsgBox("Downloading new update!")
		WebClient2.DownloadFileAsync(New Uri("http://www.yourftpsite.com/link.txt"), "C:\link.txt")
	End Sub
Go back into the FTP site again and create a new file, "link.txt" noquotes. Add inside it the DIRECT link to the new updated program. (ex. "www.blahblahblah.com/UpdatedProgram.zip")

THIS PROGRAM HAS TO BE IN A ZIP FILE!!! HAS TO BE!!!! SO PUT IT IN A ZIP FILE!!!!



Ok, now add that ZIP file wherever you put the link to. Try and add it in your FTP server on 110MB.


If it is not in a zip file the webclient will NOT download it. So put it in.

Now add beneath that code in the Coding Window:

Code:
	Private Sub WebClient2_DownloadFileCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles WebClient2.DownloadFileCompleted
		Dim Link As String = My.Computer.FileSystem.ReadAllText("C:\link.txt")
MsgBox("Please unzip the application and place in an easily accessible place.")
		WebBrowser1.Navigate(Link)
		Button1.Enabled = False
		Button1.Text = "Update already downloaded."
		Label2.Text = "Update already downloaded."
		Label2.ForeColor = Color.Red

	End Sub


You're done!

All that you need to do whenever you get an update is modify LINK.txt to the new update.ZIP!!!!!!!!! and modify version.txt to your new version. Also, go into your project properties and change the version whenever you update.



You're welcome, if anyone needs ANY help with this just post here and it will be fixed by me or someone else. THANKS FOR VIEWING!
this looks a bit to much like an updater i had in my old old injector... I updated (to much lag)
you're saying I leeched it from you?

well you can stop saying it right now xD i made this myself, no tutorials at all, but i looked up New URI on the internet.. i was sucky back then :P
Quote Originally Posted by Hawk_ View Post
you're saying I leeched it from you?

well you can stop saying it right now xD i made this myself, no tutorials at all, but i looked up New URI on the internet.. i was sucky back then :P
It is partially leeched if not fully. E.g: File Manager Image is the same as of the other tutorial I saw !! Credits Now !
i tried 100mb.com and other ftp sites but those sites need credit cards to make an account.Any other way to skip the payment page?
Use 000webhost.com, they have free hosting.
Quote Originally Posted by Lolland View Post
Use 000webhost.com, they have free hosting.
thanks for the fast reply.
but
after i sign up on the website, i need to wait for 24hrs for them to activate my account?ty
It might take some time to activate your account, but they have good servers and they're decently fast.
Quote Originally Posted by Lolland View Post
It might take some time to activate your account, but they have good servers and they're decently fast.
oh thanks for the help!loland
thanks!
And, 110mb doesnt use credit cards :S
And i didnt leech this, if i did leech some of it (looking up code strings on google) i have no idea where. xD this was about 2 years ago.
Hmmm, did my tutorial section rule go out the window?

Also, Stop flaming each other, glad to see the section "Picking up" even though it's do to the contest, (for the most part) however, why does every thread have someone calling another a "fag" or "noob" or "leecher" or something or another.

Sheesh, if you want to question somebody about leeching, do it via PM, Report them, keep it out of this section, gone for a few weeks......and already...
Opps opps opps

Seen this guide before, and i still have the link.

Credz credz credz
Quote Originally Posted by .Celtics View Post
Opps opps opps

Seen this guide before, and i still have the link.

Credz credz credz
Read the first post? Big bolded letters? Doesn't get more obvious.
AND, the image i took myself. I posted this on 3 websites or 4 i forget under xFalcon, steve323, etc..
Posts 1–15 of 20 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us