cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
shaneschmitt
Level 3

Installing a Download without being connected

I am writing my software to do a couple of different things. I would like input on how a couple of things work and how to do some things. Here is a general overview of my liveupdate program --

If I have a file already downloaded and ready for install
AskToInstall
else
AskToCheckForUpdates
If we don't check for updates then
Download in the background
endif
endif


The sample code provided to see if an update is already downloaded requires a connection to the internet.

If pagent.IsConnected() Then
UpdateCollection = UpdateAgent.EnumUpdates(GV.GUID)
For iIndex = 1 To UpdateCollection.Count
UpdateInstance = UpdateCollection.Item(iIndex)
If UpdateInstance.Download(True) = True Then
down = True
End If
Next
End If

Can I get around having to connect to see if I already have an update ready to install? I don't see the need for connecting if I have an update already downloaded.
0 Kudos
(5) Replies
Chris_Woerner
Level 10

The short answer is no. The Agent needs to enumerate the list of updates from the server again.

-----------------
Here is the long version.... When the Agent is called, it needs two pieces of information:

1. all available updates
2. status of each update (not started/ in process/ downloaded)

The list of all updates comes from the server. The knowledge of which ones are in process comes from the Agent using local knowledge. The Agent doesn't expose a way directly enumerate the list of updates that have been downloaded or are in process.
0 Kudos
CChong
Level 11 Flexeran
Level 11 Flexeran

I have been keeping a log in the application's install folder that is just a text file. It has stored all of the information that QueryValue can give me (all that I find useful anyway) for each update, including LocalDir (the location of the downloaded update). Every time an update is downloaded, I update this log to reflect that an update file currently resides on the local machine, and the log, as I said, also contains all of the other information (LocalDir, CommandLine, Title, Category, Description, etc.) for the update. I can then run the update from a command line when I am not connected. This does not require the use of the agent, and so you do not need to be connected.

My advice, if you really want to do this, is to do something similar to what I just described. Also, an integral part of the log is a flag that indicates whether or not the download completed and whether or not the update has been installed.
0 Kudos
CChong
Level 11 Flexeran
Level 11 Flexeran

I was wondering how you get all that information you mention. You say something about QueryValue, but I can't find any mention of that call in the documentation.

If you could post some sample code I would greatly appreciate it. I'm using C++, so if you have any C++ code that would be great, otherwise visual basic would be ok too.

Thanks
0 Kudos
CChong
Level 11 Flexeran
Level 11 Flexeran

All I have now is VB, and I don't have time to transpose, but the VB should give you a good idea of how to do this. Also, you are right, the .queryValue method is not well documented from what I saw. I don't know how I happened to come across it, but here it is!

Note: 'index' is the number of the update in the collection, and the collection can be treated as an array of the update messages that you have posted, including the info messages

Public Sub subDisplayAllUpdateInfo(index)
Dim UpdateAgent As Agent
Dim UpdateCollection As Updates
Dim WithEvents UpdateInstance As Update

Set UpdateInstance = UpdateCollection.Item(index) 'see Note above

MsgBox "Category = " & UpdateInstance.QueryValue(Category) & vbCrLf & _
"CommandLine = " & UpdateInstance.QueryValue(CommandLine) & vbCrLf & _
"Description = " & UpdateInstance.QueryValue(Description) & vbCrLf & _
"Details = " & UpdateInstance.QueryValue(Details) & vbCrLf & _
"DisplayVersion = " & UpdateInstance.QueryValue(DisplayVersion) & vbCrLf & _
"DownloadSize = " & UpdateInstance.QueryValue(DownloadSize) & vbCrLf & _
"DownloadURL = " & UpdateInstance.QueryValue(DownloadUrl) & vbCrLf & _
"Id = " & UpdateInstance.QueryValue(Id) & vbCrLf & _
"LocalFileName = " & UpdateInstance.QueryValue(LocalFileName) & vbCrLf & _
"ProductCode = " & UpdateInstance.QueryValue(ProductCode) & vbCrLf & _
"ProductName = " & UpdateInstance.QueryValue(ProductName) & vbCrLf & _
"TargetDir = " & UpdateInstance.QueryValue(TargetDir) & vbCrLf & _
"Title = " & UpdateInstance.QueryValue(Title), vbOKOnly, "Info"

End Sub



it may be helpful for you to see this in a loop, which would look something like this (this time in c++, though my c++ is rusty):

for (i=0;i subDisplayAllUpdateInfo(i);
}
0 Kudos
CChong
Level 11 Flexeran
Level 11 Flexeran

Thank you very much for the help.

Unfortunately I can not get it to work. It appears that the QueryValue function is not available to me. Maybe its because you have a newer version of the agent, mine is 1.21, or maybe that function isn't available in C++, or maybe something else that I can't think of right now.

Thanks for the help though.
0 Kudos