-
1 Attachment(s)
LiveUpdate. Downloads from web and updates multiple client files.
Ok, finally I have produced some code that I can post here.
This software allows developers to add "Live Update" features to their applications.
Features:
- Multi app/file auto update at the same time
- Auto update silently in background
- Use wizard to control live update
- Retrieves remote file info before downloading
- Ability to add new, previously uninstalled, software components to server for download
- Make updates mandatory
- Allow users to select which updates they would like to download
- Progress status of downloads
- Notification of download problems.
- Ability to see which updates failed/passed download.
- Cancel update download
- Authenticate username and password
One thing you need to do is to go to this web site:
http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip
and download the 2 tlb files and install them using the instructions provided.
These tlb files are used for the call back to allow the download to be shown in a progress bar, and to allow the user to cancel the download.
In the example attached the app is looking at NoteMe's server...cheers to NoteMe for letting him use his server :wave:
Here's what to do.
If you want to use your own files, on your own server, and not use NoteMes test server then do the following:
Copy the files you want to download to your web server. If you have IIS on your PC you can create a virtual directory and then use:
http://LocalHost/MyVirtualDir/
as the remote path.
Then you need to copy a file called Update.txt to the same location as your files.
The update.txt file contains info about the updates on your server.
In the example I have posted the update.txt looks like:
MDACS;MDAC Setup v2.6;2.6.3;MDAC_Setup.exe;False;False
RESUME;Wokas Resume;4.1;ResumeTEST.doc;False;True
OFFICE;MS Office Components;3.1.0056;Office.exe;True;False
ACC;Accounting Software;1.0.5;AccSetup.exe;False;True
TICKICON;Tick Icon;3;TickIcon.gif;false;False
Each column is split in VB using the ;
The columns are: Key, App Desc, Version, Filename, Mandatory, New App
So, if we take the 1st line of that file:
MDACS - This is the application/file key of the components
MDAC Setup v2.6 - This is a short desc about the remote components
2.6.3 - This is the version number of the remote file
MDAC_Setup.exe - This is the remote file to download
False - This means the download is NOT mandatory
False - This means that a previous version of this app must be installed to download this update.
When my app starts in frmUpdate I load the cuurent installed apps into the auto updator:
Code:
With mobjUpdate.Products
.Clear
.Add "MDACS", "MDAC Version v2.5", "2.5.1"
.Add "RESUME", "Wokawidgets Resume", "2.5"
.Add "IMAGE", "Splash Screen Image", "18"
.Add "OFFICE", "MS Office Components", "3.1.0054"
.Add "TICKICON", "Tick Icon", "5"
End With
These values can be in a txt file on the local machine, in the reg or whereever you like. I've just added them in directly.
Code:
mobjUpdate.RetrieveUpdates
This downloads the update file from the server, and populates the update properties.
You can then select what updates you require.
In my example I have an live update wizard AND the quick auto update...however you can do ALL the updating with an interactive UI:
Code:
mobjUpdate.RemotePath = "http://www.noteme.com/Wokawidget/"
With mobjUpdate.Products .Clear
.Add "MDACS", "MDAC Version v2.5", "2.5.1"
.Add "RESUME", "Wokawidgets Resume", "2.5"
.Add "IMAGE", "Splash Screen Image", "18"
.Add "OFFICE", "MS Office Components", "3.1.0054"
.Add "TICKICON", "Tick Icon", "5"
End With
mobjUpdate.DownloadUpdates
And then just trap the UpdatesDownload event:
Code:
Private SUb mobjUpdate_UpdatesDownload()
MsgBox "Updates Downloaded!"
End Sub
After this the InstallProductUpdates is fired:
Code:
Private Sub mobjLiveUpdate_InstallProductUpdates(ByVal Product As vbLiveUpdate.Product, Installed As Boolean)
End Sub
This is where you add code to copy files to a specific location, or launch setup applications etc. If the update passes then set Installed = True.
That's pretty much all the code is needed to download multi updates.
I have added a lot of fancy UI code into my app just to demo what can be done with the code.
If click Web Download then this just demos the vbDownload project, which can be used completely on it's own in other projects to download any files from the internet.
Any comments most welcome.
New version in Post #37!!!
Woka
PS Thanks to Klienma who stuck with me and put up with my annoying questions on how to get the URLDownload API to work with a progress bar. Cheers, this code would not be possible without your help :wave:
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Very nice:thumb:
I have a question:
If I want to send my program to someone, will I have to send him the tlb files too?
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
err...yea.
The app above requires the following to be registered on the PC.
olelib.tlb
olelib2.tlb
This are installed by office though, so if the PC has office I believe this arn't needed.
Then you need to register
vbDownload.dll
and
vbLiveUpdate.dll
I am currently rewritting vbDownload.dll as I found a slightly better method that runs asynchronously. Hopefully I will get this done tonight, but not promising anything.
I take it the code worked on your PC?
Did you email me today?
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Yeah, worked fine on my PC :)
Well actually, I dont need the live update feature, I might need in the future the WebDownload one.
I have seen you post this somewhere else...
I see that this version requiers the download.dll file...
If I need the WebDownload, I'll search the forums and I'll find it :afrog:
I'll currently use the URLDownloadToFile api...
If I have time, and I'm not bored, I might update to yours...:bigyello:
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
I use the URLDownload API function too.
I use the tlb files for a call back so that I can control a progress bar with it.
I am not happy with this function though as it's not asynchronous :(
The web download is the vbDownload.dll
If you don't want to use the dll just add the download class directly into your app.
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
I want to do a little more with the liveupdate. On my web site I sell subscriptions to updated drug formularies. Users subscribe at different rates to get access to more or less informaton. My .asp download pages on the web are protected by an MS-Access password file. Code on each page checks that users are registered and allows access based on subscription level. Is there a way to have the update script in my program check the password file on my web site before allowing the download process to proceed? Examples?
Thanks
tbyrne
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
I like your sample! Helped me!
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Quote:
Originally Posted by tbyrne
I want to do a little more with the liveupdate. On my web site I sell subscriptions to updated drug formularies. Users subscribe at different rates to get access to more or less informaton. My .asp download pages on the web are protected by an MS-Access password file. Code on each page checks that users are registered and allows access based on subscription level. Is there a way to have the update script in my program check the password file on my web site before allowing the download process to proceed? Examples?
Thanks
tbyrne
You could use the inet control, or winsock, to open an asp page which will then validate the password and username, you write the response to the page. Then when u receive the page, you check to see if the login was successfull.
I will try and dig out some code.
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Quote:
Originally Posted by DarkX_Greece
I like your sample! Helped me!
Cheers :)
WOka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Thanks Woka
All the code/examples you can find is greatly ppreciated.
Tbyrne
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
I have a question -
Lets say my application, called aijii.exe were to invoke a liveupdate, and one of the files to be updated was aijii.exe... how would I actually successfully copy this over itself whilst the program was still running ?
Is there another way to do this ?
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
This is a good question.
It's the same if you download an update for vbLiveUpdate.dll :D
You must use an installer like Inno Setup to install your app.
This creates an install package like most apps you download from the web have.
If the Setup package can't replace a file at runtime, because it's being used, then it tries to restart your system...like some setups do.
When the system restarts the old files are over written with the new.
There is a link to the Inno homepage in my sig.
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Our app is currently using installshield, I assume the same applies.....
So I guess we just have liveupdate or webdownload download the patch file and execute it from the application... OR we could just have a run.exe file that the user executes, this first checks for updates, then executes our main application......
hmmm..
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Hahaha...Which method you gonna pick?
Yea, install shield will do it for ya.
I'd go for run.exe then you can add:
VB Code:
If App.PrevInstance Then
MsgBox "LiveUpdate is currently running."
Else
'code to do liveupdate stuff
frmMain.SHow
'etc
End If
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Not sure yet - I haven't quite played too much with your code yet... I still have a few question marks.....
The business rules here are that the user MUST upgrade, but having it reboot their system isn't really preferable as the software will be running on point of sales systems... I'm thinking the run.exe solution is the easiest....
just a quick question - how hard will it be to have the auto live update use the progress bar like in web download ? or have the webdownload check to see if updates are required ?
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Errrr...When live updates runs in the back ground I just haven't given it a user interface. Sure it's 100% possible...just add a progress bar nad trap the evens of the liveupdate object...:confused:
Errr...it already does check to see what updates are required...:confused:
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Err .. sorry i worked this out myself anyway .. should have just deleted the post.. sorry i tend to get a bit lazy and post questions up before i can be bothered trying it out.
Anyway, works very well, cheers!
Just a question, in 'installproductupdates', how do I know what the actual filename of the file that corresponds to that update is ?
EDIT: rephrase- how does the application know what the filename is ... short of hardcoding it i mean..., also how does it handle authentication ?
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Quote:
Originally Posted by Wokawidget
err...yea.
The app above requires the following to be registered on the PC.
olelib.tlb
olelib2.tlb
This are installed by office though, so if the PC has office I believe this arn't needed.
Then you need to register
vbDownload.dll
and
vbLiveUpdate.dll
I am currently rewritting vbDownload.dll as I found a slightly better method that runs asynchronously. Hopefully I will get this done tonight, but not promising anything.
I take it the code worked on your PC?
Did you email me today?
Woka
How are you able to register the .DLL files when they arent even present in the download?
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Errr...the VB projects do exist. U need to compile the projects into DLLs.
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Quote:
Originally Posted by Wokawidget
Errr...the VB projects do exist. U need to compile the projects into DLLs.
Woka
Ok. I compiled the group project and found a few problems that you might not be aware of.
When you click on Live Update button, and use the Wizard.
When you get the msgbox saying "Remote Information Not Found." you then get a run-time error '91': Object variable or With block variable not set. and then you get run-time error '440': Automation error.
The run-time error '91' highlights:
VB Code:
Private Sub UpdateInstallStatus()
txtStatus.Text = lvwResults.SelectedItem.Tag
End Sub
in frmWizard.frm
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
I had/have the same problem...
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Soooooooo sorry for the late reply :(
Been working really hard and have neglected my projects...Boooo bad Woka *SLAP*
VB Code:
Private Sub UpdateInstallStatus()
If Not (lvwResults.SelectedItem Is Nothing) Then
txtStatus.Text = lvwResults.SelectedItem.Tag
End If
End Sub
That should do the trick :D
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Looks like it's working well...
:thumb:
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Not to sound newbish or anything, but do you think you can explain this a little more. I have been looking for an auto-update for awhile now. As you can see I have finally found one, but I cant quite understand how to use it. What I mean is like some easier instructions on using it. It sounds good from the feedback, really need it :ehh:
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
What would be the best way to add this to my application.
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
hi. i am travelling europe at the noment and am in a cafe using a silly french keyboard.
there is no vb oàn this machine either.
I will be bqck in just over a week where I will be able to hlp you oot:
woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Thanks Much Woka! I love the app though! :thumb:
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Sorry for the late replies :(
To add this to your app just compile the vbLiveUpdate dll, and then reference this into your app and then use it like I have in my demo app.
You app would then add products and control the functions in the dll.
Is that what you mean?
This project isn't easy. It really isn't for people who don't know VB :(
I can't really give huge chats on how it works etc, and how to get it running in everyones apps, as I would be doing this full time.
If you have any questions can you make them I little bit more specific as it's much easier for me to answer them then :D
Wooof
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Hey Woka,
The 2 tlb files you refer to at the beginning, but im a little confused?! :confused:
I downloaded the link you provided (http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip) which contained a whole bunch of *.inc files, olelib.tlb, olelib.odl, a folder named "Implements" with some more *.inc files, olelib2.tlb, olelib2.odl.
Now, I assume the 2 tlb files you were referring to are olelib.tlb and olelib2.tlb, but would I copy these to my system directory and register them there, or copy them to my app directory and reg them there?
A little help please :(
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Copy them to the system directory.
Instructions are on that web site...arn't they?
I think I may have a newer version that doesn't require the tlbs. I'll ses if I can dig it out.
WOka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
A newer version of the live update?
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Quote:
Originally Posted by Wokawidget
Copy them to the system directory.
Instructions are on that web site...arn't they?
I think I may have a newer version that doesn't require the tlbs. I'll ses if I can dig it out.
WOka
If there is a newer version that doesnt require the TLB files then i would definately be interested in it for my new app.
Also, what I would be looking to do with your code is to update the complete program (exe) can your app do this? i am sure it can. Same for .chm files.
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
I'll see if I can post it tonight, but can't promise anything as the computer is out of bounds when the girlfriend is round :D
The app can update anything. It can simpley download a txt file and copy it into a folder if you want, or it can download a setup.exe (this is what you would do)
Once you download teh setup.exe, you launch the exe, and at the same time you close down your app and the liveupdate window.
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Quote:
Originally Posted by Wokawidget
I'll see if I can post it tonight, but can't promise anything as the computer is out of bounds when the girlfriend is round :D
hehehe! whipped i see! lol!
Quote:
Originally Posted by Wokawidget
The app can update anything. It can simpley download a txt file and copy it into a folder if you want, or it can download a setup.exe (this is what you would do)
Once you download teh setup.exe, you launch the exe, and at the same time you close down your app and the liveupdate window.
Woka
Sounds like a plan. I hope to get to your level of expertise one day ;)
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Hey Woka,
:wave: Just wondering if you got around to digging up the files for liveupdate. Don't mean to rush you.
Thanks
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Sorry. Just got back from Dublin, Ireland. Had mad weekend for my birthday. GF suprised me with tickets.
Anyways, the code is attached below
Woof
-
1 Attachment(s)
Re: LiveUpdate. Downloads from web and updates multiple client files.
New Version
Uses winsock to download the files instead of the URLDownload API.
This gives you true async download.
The code is exactly the same as b4, apart from the vbDownloader project has been altered to use winsock instead of the API.
Woka
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Thanks woka!!! :thumb: and happy (belated) birthday!!
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Sorry, one more question. Does this source require the 2 .tlb files?
edit:
and can the liveupdate download from an FTP server? :confused:
-
Re: LiveUpdate. Downloads from web and updates multiple client files.
Hey Woka,
I've been testing out the liveupdate and I have run into some problems:
1) Whenever I set the .SaveTo path to a subfolder of a drive, or any folder OTHER THAN the root path of a drive, I get a path not found error.
2) I have made a folder on my server (at {link removed}). This folder contains Updates.txt, with the necessary information in it, as well as 2 exe files that i would like to download in the liveupdate (which are referenced in the Updates.txt file. When I run the liveupdate, it seems to find the Updates.txt file properly, but doesnt seem to download anything, and it finishes with a successful message. No downloads though.
This is the code I changed in the liveupdate demo source you supplied with the zip file:
Form_load event:
VB Code:
Private Sub Form_Load()
Set mobjLiveUpdate = New LiveUpdate
mobjLiveUpdate.server = "www.acmdesigns.ca"
mobjLiveUpdate.RemotePath = "clients/sss_lu/"
mobjLiveUpdate.SaveTo = "C:\"
End Sub
AddProducts sub routine:
VB Code:
Private Sub AddProducts()
Dim x As Integer
Dim arrProducts() As String
x = 1
With mobjLiveUpdate.Products
.Clear
Do Until GetSetting("TrinityScheduler", "LiveUpdate", x) = ""
'arrProducts = Nothing
arrProducts = Split(GetSetting("TrinityScheduler", "LiveUpdate", x), ";")
.Add arrProducts(0), arrProducts(1), arrProducts(2)
x = x + 1
Loop
End With
End Sub
The rest is the same as the demoUI code from the example vb project you made.
Any help would be appreciated! Thanks.