Click here to Skip to main content
15,908,776 members
Articles / Programming Languages / Visual Basic
Article

AutoUpdate for VB.NET

Rate me:
Please Sign up or sign in to vote.
3.31/5 (8 votes)
1 May 2008CPOL1 min read 79.1K   3.8K   32   32
This is a DLL library to check for updates for your application.

Introduction

You can use this library for checking for updates for your application. It's simple and small (only one function). The update package must be a zip file.

Using the Code

The DLL only contains one function: CheckForUpdates in the AutoUpdate namespace.

It has the following arguments:

  • NewestVersionLocation As String - This is the file location on the Internet where your newest version is placed, in plaintext. The file can only contain, for example: 2.0.
    You can use a *.txt file for this, but any extension is possible.
  • NewestVersionDownloadLocation As String - This is the file location on the Internet where your newest application (files) are stored in a zip file.
  • UnzipDir As String - This is the directory where the files must be extracted. If you use an empty string, or you omit this argument, the startup path of the application is used.
  • DisplayWindow As Boolean - With this, you can choose to display the download window or not.
  • MsgBoxText As String - This is the message displayed in a MsgBox if there is an update available.
  • MsgBoxTitle As String - This is the title of that MsgBox.

For the source code, download the zip file above, it has comments on my own written code.

Using an empty string for the last four arguments means the same as omitting them.

Example to Use

VB.NET
AutoUpdate.CheckForUpdates(http://yourdomain.com/versions/app.txt, _
    "http://yourdomain.com/update_downloads/app.zip", "", True, _
    "Newer version available. Download it?", "")

References

History

  • 1st May, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
General'Ionic.Utils.Zip.ZipFile' is not defined Pin
vidhyaej7-Feb-10 19:12
vidhyaej7-Feb-10 19:12 
GeneralRe: 'Ionic.Utils.Zip.ZipFile' is not defined Pin
pimb27-Feb-10 19:42
pimb27-Feb-10 19:42 
QuestionAbout the updater Pin
MatthewAuld23-Apr-09 23:05
MatthewAuld23-Apr-09 23:05 
AnswerRe: About the updater Pin
pimb224-Apr-09 4:37
pimb224-Apr-09 4:37 
AnswerRe: About the updater Pin
MatthewAuld25-Apr-09 20:58
MatthewAuld25-Apr-09 20:58 
QuestionAn example? Pin
davistv22-Jun-08 22:19
davistv22-Jun-08 22:19 
AnswerRe: An example? Pin
pimb28-Dec-08 8:28
pimb28-Dec-08 8:28 
GeneralAdding a feature Pin
Member 165764123-May-08 5:34
Member 165764123-May-08 5:34 
I want to modify this code alittle and add this to it
where should it be added This is kinda long original code with issues at the end

I want to do this instead of how you have it..

you call updater.exe
It checks for updates
'if update is found do this

if update is found return 1
if update = 1 then
'Check to see if program is running
Dim myProcesses() As Process
Dim instance As Process
myProcesses = Process.GetProcessesByName("NameOfProgramToKillProcess")
For Each instance In myProcesses
killProcess("NameOfProgramToKillProcess")
' Then prompt to download the update

else
MessageBox.Show("No update is available")
me.close
end if

Problem here is having AutoUpdate.dll to pass back the yes or no there is a update. 1 for yes 0 for no
If yes(1) prompt to download if no(0) then show messagebox no downloads available and then close the updater

I have this to the point now if update is available it prompts to download and kills the other process but its not working correctly, and it of course won't tell me if updates were not available. I felt if users run it, and it just goes through the process they will think is broke. also I don't want to close the application unless the update it there. Right now this is what happens

I run updater.exe (No updates) it exits
updates it prompts me if the other program is running, and asks me if i want to close it and get updates
if i say yes then it downloads them and exits
if i say no it exits

under this scenerio all is well accept two things
1. no prompt that updates wasn't available
2. if program was running and it kills the process and it exits that program and does the update
but when i restart the apllication, some where outa the blue it trys to download updates again.. Like something from the past is still running.. and i do not have any of the updater code in the original project i killed the process one.. Maybe the autoupater process hasn't died and is running in the background (have't checked that yet)
3. if program is not running and updates take place all works exactly as I wish, but doesn't prompt me..if updates wasn't available..

so basically the issue..vb.net 2005
if i kill the process of the original running program something goes wrong..and i am not being prompted for no updates avaibale...

Any pointers?

Here is what i am running in code in updater.exe


Try
Dim myProcesses() As Process
Dim instance As Process
myProcesses = Process.GetProcessesByName("NameOfProcessIAmKilling")
For Each instance In myProcesses
'Its running do your thing
Dim Ans As MsgBoxResult

Ans = MsgBox("Auto Restoration is currently running. We need to close Auto Restoration before checking for updates is this ok?", vbYesNo + vbExclamation, "Auto Restoration Is Running")
' If the user clicked no exit sub
If Ans = MsgBoxResult.No Then
MessageBox.Show("Checking for updates was aborted")
Exit Sub

ElseIf Ans = MsgBoxResult.Yes Then
killProcess("NameOfProcessIAmKilling")
getupdates()
Exit Sub
Else
getupdates()
Exit Sub
End If

Next
Catch ex As Exception

End Try


getupdates()


Sub getupdates()
AutoUpdate.CheckForUpdates("http://IPAddrress/versions/NameOfProcessIAmKilling.txt", _
"http://70.62.12.101/versions/downloadVersionsName/NameOfProcessIAmKilling.zip", "", True, _
"Newer version of Auto Restoration is available. Download it Now?", "")
Me.Close()
End Sub
GeneralRe: Adding a feature [modified] Pin
pimb28-Dec-08 8:14
pimb28-Dec-08 8:14 
QuestionWhat about app.exe? Pin
Megalan4-May-08 5:34
Megalan4-May-08 5:34 
AnswerRe: What about app.exe? Pin
pimb25-May-08 1:53
pimb25-May-08 1:53 
GeneralRe: What about app.exe? Pin
Megalan5-May-08 3:27
Megalan5-May-08 3:27 
GeneralRe: What about app.exe? Pin
pimb26-May-08 2:05
pimb26-May-08 2:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.