Page 1 of 1

Forcing an App Update from within a VB2005 application

Posted: Fri Mar 23, 2007 7:56 am
by DaveW14
Probably been asked a 1000 times but Iv missed it 1000 times too....
Sorry.

Having setup the Web based 'Receive Application Updates' and it working OK, However I would like to be able to force this when my application opens or upon a menu option to ensure its the latest version.

The reason is that the scheduler by default nicely sets itself up at 3AM on Sunday by default and people may not change this - or they dismiss the scheduler alert so do not get an update. PS. I cannot find a way to force this scedule to 'daily' upon install.

So, I guess this maybe to shell or call a command within the windows application to something like what the scheduler would call but this does not seem to work.

Please does anyone know of a process for this?

Thanks
Dave

Posted: Fri Mar 23, 2007 4:05 pm
by gsmmc
This is something I imagine you would handle in your application.

For example, you could assign an application version number to your app that is the same as the installaware version specified, and then look to the update.ini when a user logs in to determine if an update is needed.

Another option would be to just execute InstallAware's /update each time someone logs into the application if you want to make sure the user is always aware that updates are available. A downside to this approach is that you may end up with multiple InstallAware icons in the system tray for each time the person logged in and didn't close the installaware tray icon (that can get annoying).

Hope this helps,
GS

Posted: Mon Mar 26, 2007 11:26 am
by DaveW14
Thanks GS,

The IA auto updater unfortunately does not appear to be reliable in its ability to find that an update is available - even if the ini files says one is for a particular version, so any process which will help, will.. Either that I or will build my own.

Re /update. I thought this update mode was only available with <setup> /updatesetup or <setup> /update. So if the user downloaded the setup.exe installed and deleted the setup.exe, then how can I execute the 'InstallAware's /update' ?

Thanks
Dave

Posted: Wed Mar 28, 2007 3:53 pm
by gsmmc
You can use the InstallAware Updates Shortcut (.lnk) found in C:\\Windows\\Installer directory to initiate the updates.

I recommend checking for the file at %windir%\\Installer\\ or %SYSTEMROOT%\\Installer

This seems to be a fairly reliable approach although it may also require administrative privilages on the local machine (I haven't tested that)..

GS

Posted: Thu Mar 29, 2007 2:45 am
by Ton_B
In our application we had the same problem. (VB 6)
What we have done is to compare the currently installed version with the exe-version of the setup.

Before you can use this you will have to create a custom registry entry during the installation where you can put the versionnumber into.
eg: SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$PRODUCTNAME$
We have placed a key "DisplayVersion" there.

When you start your application, all you have to do is compare this version number with the internal exe version of the setup.
You can use the API-call GetFileVersionInfo to retrieve this information.
(file attached)
you also need a API-call (RegQueryValueEx) to read registry entries (also attached in the zip file, it contains the function "GetString")

simply use these lines of code: (i've created a function wich returns true if an apdate is needed, false otherwise.

Code: Select all

public function UpdateNeeded() as boolean
CurrentVersion = GetString(SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\'yournamehere'\\ , "DisplayVersion")
  sVersion = GetVersion("c:\\setupfiles\\myproject.exe)
  'if the version format is like [major.minor.revision] you have to split the
  'data into seperate numbers
  vAvailableVersion = Split(sVersion, ".")
  vInstalledVersion = Split(CurrentVersion, ".")


      If CInt(vAvailableVersion(0)) = CInt(vInstalledVersion(0)) Then 'Major.new = Major.current
        'there is no major update available, bu maybe ther is a minor update
        If CInt(vAvailableVersion(1)) > CInt(vInstalledVersion(1)) Then 'Minor.new = Minor.current
          UpdateNeeded = True
        End If
      ElseIf CInt(vAvailableVersion(0)) > CInt(vInstalledVersion(0)) Then 'Major.new = Major.current
        'there is a major update !
        UpdateNeeded = True
      End If
end function



Hope this helps.

File Attached:

VersionInfoAndRegisrty.zip