|
I have implemented AutoUpdate in a project on which I am working and
thought I would share the implementation and changes I made to the AutoUpdate.dll.
Pimb's program is excellent and by having the source I
could hack on it. Thanks Pimb. I even learned a little Dutch!
In my application I need to download the executable that is running when AutoUpdate is first called.
Pimb showed how to do that in an earlier post. But I didn't want to close the application until after AutoUpdate had
determined that there was in fact an update. After the update is complete, I also wanted to give the user the option to restart the newly updated application. I have created two zip files. One has the source and my diffs and the other has two projects. I cannot figure out how to upload the files! Now that should inspire a lot of confidence. As soon as I do I will upload them. Pimb I am sending them to you in an e-mail.
The Autoupdate project is my revised AutoUpdate. The substantive changes are to move the code to kill the process that will be updated into AutoUpdate and to ask if the user wants to restart after the update. I also compiled with strict on so that I needed to cleanup some declartions and one typo. While doing this I inserted the new Ionic.Zip.dll that now uses a different name and namespace.
The Updater project is the console application that calls AutoUpdate and it in turn is called by the program being updated. As Pimb said earlier this must be a console application. The program takes two arguments the name of the process being updated (calling process) and the name of the program which can be used in dialogs. Both the process and program
are now optional parameters to AutoUpdate.CheckForUpdates. If the user doesn't want to kill a process or use a product name then just not pass the arguments in to AutoUpdate.CheckForUpdates.
I think it might be helpful to show how I use all this.
In my main application I have a menu item--Check for updates--which is handled like this:
Private Sub CheckForUpdateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckForUpdateToolStripMenuItem.Click
' http://dotnetperls.com/process-start-examples-vbnet
' New ProcessStartInfo create
Dim p As New ProcessStartInfo
' Specify the location of the binary
p.FileName = "UpDater.exe" 'This is the console application that calls the AutoUpdate
' Use these arguments for the process
p.Arguments = Process.GetCurrentProcess.ProcessName & " " & ProductName
' Use a hidden window
p.WindowStyle = ProcessWindowStyle.Hidden
' Start the process
Process.Start(p)
End Sub
UpDater.exe is the console application that calls AutoUpdate. My module to create it looks like this:
Module Updater
Sub Main(ByVal args() As String)
Dim processName As String = args(0)
Dim ProductName As String = args(1)
getupdates(processName, ProductName)
End Sub
Sub getupdates(ByVal ProcessName As String, ByVal ProductName As String)
AutoUpdate.CheckForUpdates( _
"http://billhogsett.com/wordFrequency/wordFrequencyVersion.txt", _
"http://billhogsett.com/wordFrequency/wordFrequencyUpdate.zip", "", True, _
"A new version of " & ProductName & " is available. Download it Now? " & ControlChars.CrLf & ProductName & _
" will be closed.", "wordFrequency Updater", ProcessName, ProductName)
End Sub
End Module
Sorry for the lousy formatting of this message.
Bill
|
|
|
|
|
|
Thanks very much for your improved version of the updater. However, it's a long time ago I wrote this code and I'm a bit busy at the moment, too. I'll take a look at your code in a week if you don't mind. Also, I'm afraid I got a security error when extracting your source code zip file, the file 'Downloaden.Designer.vb'. What could be the reason for that?
I think I will also spend some time again in, if needed, update the whole project as I've learned a lot in the meantime anyway.
Thanks very much.
|
|
|
|
|
I have no idea what would cause the security error in Downloaden.Designer.vb. If others have the problem I'll recreate the zip and announce that here. Look for the file in your mailbox.
I recall from one of your earlier messages that you had finished the project for which you needed the AutoUpdate.dll so I understand you may not be doing anything with it now.
I may revisit my changes next week and see if they still look good after a few days.
Bill
|
|
|
|
|
I have downloaded well, I had no problem. I will check it. The solution was made with VS2010 ?
|
|
|
|
|
Yes, I used VS 2010 beta 2 to make the autoupdate.
If you have any issues or questions let me know.
I am still working on the project for which I needed autoupdate and may release another version.
Bill
|
|
|
|
|
Ok, I wll wait you. If there is some possibilty, please "save it" as VS2008. Thanks a lot.
|
|
|
|
|
I will not have anything for you until Friday.
|
|
|
|
|
I regretfully have to say that I forgot about it a little bit. I'm quite busy at the moment, and as this is more like a 'leisure activity' for me, I must say that I cannot spend all of my time on it.
Also, I have Visual Basic Express Edition 2008. Just because you said you made it in VS2010, I was wondering if I could load and use your tweaked version with no problems.
Thanks.
|
|
|
|
|
I doubt that creating the program in Visual Studio 2010 is an issue. But what will be an issue--solvable I think--is that I compiled the program with the .Net 4.0 libraries. So without a recompile (should be trivial) the program will work only if the user has the 4.0 libraries.
I'll put together a version using the 3.0--maybe even 2.0--libraries.
I also think I have gone back to the original Ionic.Utils.Zip library because it is so much smaller than the current version. I have also generalized the call to my Updater program so that all the configuration is done in the arguments to Updater and none in updater itself. Defaults still come from your autoupdate.
I understand this is not a priority for you, so don't worry if you don't get around to looking at my work. I am satisfied with what I have.
Bill
|
|
|
|
|
hi..
very very thanku for your previous reply,infact i missed to add reference...
but my new problem is, i have created a new application where i have written the code below .but i am getting the following error Name ' Autoupdate ' is not declared ...
please bear with me if my question appears to be silly...but i need your help since i am a beginner...thanks in advance......
Try
Dim myProcesses() As Process
Dim instance As Process
myProcesses = Process.GetProcessesByName("app") 'replace app with your main app exe filename without .exe
For Each instance In myProcesses
Dim Ans As MsgBoxResult
Ans = MsgBox("--App-- must be closed in order to check for updates. Do you want to close -App-- now?", vbYesNo + vbExclamation)
If Ans = MsgBoxResult.No Then
MsgBox("Checking for updates was aborted")
End
ElseIf Ans = MsgBoxResult.Yes Then
instance.kill() 'I don't know if this works but it means that the main app (instance) has to be killed
getupdates()
End If
Next
Catch ex As Exception
End Try
Sub getupdates()
AutoUpdate.CheckForUpdates("http://www.yourserver.com/versions/app.txt",
"http://www.yourserver.com/versions/download/app.zip", "", True,
"Newer version of app is available. Download it Now?", "")
Me.Close()
End Sub
|
|
|
|
|
Have you also added a reference to the actual DLL that the article is about? It is also in the zip file.
PS: could you please reply rather than create a new message?
|
|
|
|
|
Thanku friend.....i got it....
|
|
|
|
|
hi.....
Now my project contains three parts....
1.my main application which is to be updated ,say abc.zip
2.The application 'AutoUpdate' which i have downloaded along wih dll
3.A new application 'StartUp' which contains the following code
.......what shoul i do next ......can u help me to proceed with...
(i have made changes to the names of the files as required)
Try
Dim myProcesses() As Process
Dim instance As Process
myProcesses = Process.GetProcessesByName("app") 'replace app with your main app exe filename without .exe
For Each instance In myProcesses
Dim Ans As MsgBoxResult
Ans = MsgBox("--App-- must be closed in order to check for updates. Do you want to close -App-- now?", vbYesNo + vbExclamation)
If Ans = MsgBoxResult.No Then
MsgBox("Checking for updates was aborted")
End
ElseIf Ans = MsgBoxResult.Yes Then
instance.kill() 'I don't know if this works but it means that the main app (instance) has to be killed
getupdates()
End If
Next
Catch ex As Exception
End Try
Sub getupdates()
AutoUpdate.CheckForUpdates("http://www.yourserver.com/versions/app.txt", _ 'this is the txt-file on your server in which the newest version number is. The address of the txt-file can be everything, it doesn't need to be in /versions/
"http://www.yourserver.com/versions/download/app.zip", "", True, _ 'this is a zip-file on your server in which all new files of your app are in (which are going to be extracted on the user's computer). The address of the zip-file on the Internet can be everything, it doesn't need to be in /versions/download/
"Newer version of app is available. Download it Now?", "")
Me.Close()
End Sub
|
|
|
|
|
Not sure what you mean here. Could you explain in more detail and in well-formatted sentences please?
|
|
|
|
|
Actually i have an application - PYM.exe which is run in 30 of my client systems......after adding new features to PYM.exe i should make it available in all the 30 client systems...
to do the same, i am now using your AutoUpdate program......
how can i implement it successfully....i am having 3 parts now with me :
1.my main application which is to be updated
2.The application 'AutoUpdate' which i have downloaded along wih dll
3.A new application which i developed just to paste the following code
Try
Dim myProcesses() As Process
Dim instance As Process
myProcesses = Process.GetProcessesByName("app") 'replace app with your main app exe filename without .exe
For Each instance In myProcesses
Dim Ans As MsgBoxResult
Ans = MsgBox("--App-- must be closed in order to check for updates. Do you want to close -App-- now?", vbYesNo + vbExclamation)
If Ans = MsgBoxResult.No Then
MsgBox("Checking for updates was aborted")
End
ElseIf Ans = MsgBoxResult.Yes Then
instance.kill() 'I don't know if this works but it means that the main app (instance) has to be killed
getupdates()
End If
Next
Catch ex As Exception
End Try
Sub getupdates()
AutoUpdate.CheckForUpdates("http://www.yourserver.com/versions/app.txt", _ 'this is the txt-file on your server in which the newest version number is. The address of the txt-file can be everything, it doesn't need to be in /versions/
"http://www.yourserver.com/versions/download/app.zip", "", True, _ 'this is a zip-file on your server in which all new files of your app are in (which are going to be extracted on the user's computer). The address of the zip-file on the Internet can be everything, it doesn't need to be in /versions/download/
"Newer version of app is available. Download it Now?", "")
Me.Close()
End Sub
what should i do next...?
hope you have understood what i really want to know....
|
|
|
|
|
If you run the application with the code you have provided, it should update the main application. After that, you can run the updated main application again. I don't think it'd be any more difficult.
|
|
|
|
|
Is it possible to give the path of app.txt and the zip file as following where N is a network drive...
but i find that the program is not running....can u help me please
Sub getupdates()
AutoUpdate.CheckForUpdates("N:/Deployment/versions/app.txt", "N:/Deployment/PYM.zip", "", True, "Newer version of app is available. Download it Now?", "")
Me.Close()
End Sub
|
|
|
|
|
Not sure about that. In fact, I use a downloader from another website. I don't know if it can handle the file protocol as well. Could you perhaps try file:///N: instead of just N: ? Also, perhaps you should use \ instead of /. Again, I have not built the downloader itself. Please reference to the link in the article and ask there if it's possible to use local/network files,
|
|
|
|
|
hi...... ,
First of all let me thank pimb2 for putting forth a method for auto update of applications.......
i was trying to do the same which automatically copy the files of the newly compiled application to the old version......
but my problem is i am getting the error Type 'Ionic.Utils.Zip.ZipFile' is not defined
can u help me guys.......?i think i have to link it to dll....but how...?
Given below is my code .....
Public Function CheckForUpdates(ByVal Location As String)
Dim temppath = IIf(Environ$("tmp") <> "", Environ$("tmp"), Environ$("temp")) 'Get temp path
Dim rand = Int((10000 - 1 + 1) * Rnd()) + 1 'Generate random number to have an unique filename
Dim dldname = Path.GetFileName("N:\Deployment\PYRAMID") 'Get filename of file to be downloaded
DownloadFileWithProgress("N:\Deployment\PYRAMID", temppath.ToString + "\" + rand.ToString + dldname) 'Download the file
Dim a = New Ionic.Utils.Zip.ZipFile(temppath.ToString + "\" + rand.ToString + dldname) 'Create new var with zip file
For Each zipfile As Ionic.Utils.Zip.ZipEntry In a 'for each loop for every file in zip
If My.Computer.FileSystem.FileExists(vars_unzipdir + "\" + zipfile.PYRAMID) Then 'If this file already exist, delete it
My.Computer.FileSystem.DeleteFile(vars_unzipdir + "\" + zipfile.PYRAMID)
End If
zipfile.Extract(vars_unzipdir) 'Extract this file
Next
Return Nothing
End Function
|
|
|
|
|
It should work. Do you have the Ionic.Zip.dll file referenced? It is included in the zip file.
|
|
|
|
|
I did everything you said to but my program just doesn't update at all... :\ it reads the txt file and says 1.0.0.7 can't be converted to long... Any ideas?
Try
Dim myProcesses() As Process
Dim instance As Process
myProcesses = Process.GetProcessesByName("Runetips RS Kit") 'replace app with your main app exe filename without .exe
For Each instance In myProcesses
Dim Ans As MsgBoxResult
Ans = MsgBox("Runetips RS Kit must be closed in order to check for updates. Do you want to close Runetips RS Kit now?", vbYesNo + vbExclamation)
If Ans = MsgBoxResult.No Then
MsgBox("Checking for updates was aborted")
End
ElseIf Ans = MsgBoxResult.Yes Then
instance.Kill() 'I don't know if this works but it means that the main app (instance) has to be killed
getupdates()
End If
Next
Catch ex As Exception
End Try
|
|
|
|
|
I'm really sorry that it doesn't work properly for you. Unfortunately, it has been a long time since I last worked with it, partly because the rating was quite low and I only needed it once for one of my applications. I'll test it again with a sample application soon.
However, something like 1.0.0.7 cannot be converted to Long - a Long is a number with just one decimal. Does my add-on try to convert it or are you trying that yourself? If it's my fault, I'm really sorry and will try to look at it.
I'm going on holidays the day after tomorrow, so I hope you don't mind if it will last somewhat longer.
Thanks.
|
|
|
|
|
It's ok man, just want to figure out how to build an auto update for my client... it's really god program and has alot of updates constantly but I got lost.. meh, Thanks anyways. You did great, and it was your thingy looking for the long.
|
|
|
|
|
This looks really useful, but I can't figure out what kind of assumptions you're making. Do I need to just upload an uncompressed folder built from the file publishing process? When I increase the version number right now, nothing happens.
A short example would be very helpful.
Thanks,
Troy
|
|
|
|