I have been running some tests and have experienced some odd behavior. Let me start with a bit of background information.
For my tests, I have 3 versions of a tool named AAA_BBBBB-CCC. The versions are 1.0.0, 1.1.0 and 1.2.0. As a part of the installation package, each version includes the updater.exe (which I have named AAA_BBBBB-CCC_Updater.exe) and updater.ini (AAA_BBBBB-CCC_Updater.ini).
I have a background process that periodically checks for updates. It runs the following algorithm by executing the updater that is currently installed.
// Check if update is available
Execute AAA_BBBBB-CCC_Updater.exe /justcheck
If return code = 0
// Update is available. Check if update has been downloaded
Execute AAA_BBBBB-CCC_Updater.exe /justcheck –installready
If return code = 0xE0000011
// Update is available but not yet downloaded. Download the update
Execute AAA_BBBBB-CCC_Updater.exe /silentall –nofreqcheck –justdownload
Else If return code = 0
// Update is available and is already downloaded
Enable button that allows user to install the update from the download folder
End If
Else If return code = 0xE0000011
// No update is available, so do nothing
End If
And now for the issues. I will start with the simple one.
Issue 1:
For this test, I have the following setup on my web server.
Folder AAA_Updates
- AAA_BBBBB-CCC_setup_v1.2.0.exe
- AAA_BBBBB_CCC_Updater.txt (updater file that downloads 1.2.0 from AAA_Updates)
Folder AAA_Updates_Test
- AAA_BBBBB-CCC_setup_v1.2.0.exe
- AAA_BBBBB_CCC_Updater.txt (updater file that downloads 1.2.0 from AAA_Updates_Test)
I start with v1.1.0 installed. Upon checking for updates (either by running the updater directly or via the /justcheck option of my background process), an aiu file is downloaded to a subfolder of the ProgramData folder.
If the ini file points to AAA_Updates_Test\AAA_BBBBB_CCC_Updater.txt, the name of the aiu file in ProgramData is AAA_BBBBB_CCC_Upd.aiu.
If the ini file points to AAA_Updates\AAA_BBBBB_CCC_Updater.txt, the name of the aiu file in ProgramData is AAA_BBBBB_CC.aiu.
I need to know the name of the aiu file programmatically so I can open the file to generate the filename with full path of the installation package that is downloaded. Why are the names of the aiu files different? What is the algorithm used to create this filename?
Issue 2 – This one is more complex, so I have provided a lot of detail:
For this test, I have the following setup on my web server.
Folder AAA_Updates
- AAA_BBBBB-CCC_setup_v1.1.0.exe
- AAA_BBBBB-CCC_setup_v1.2.0.exe
- AAA_BBBBB_CCC_Updater.txt (updater file that installs 1.2.0)
- AAA_BBBBB_CCC_Updater_XX.txt (updater file that installs 1.1.0)
I start with version 1.0.0 installed. The AAA_BBBBB-CCC_Updater.ini contains these 2 lines in particular
- DownloadsFolder=C:\ProgramData\<Company>\AAA_BBBBB-CCC\updates\
- URL=
https://www.server.com/AAA_Updates/AAA_ ... ter_XX.txt
By pointing the URL to AAA_BBBBB_CCC_Updater_XX.txt, the ini file is set up so that it will download and install version 1.1.0 when the updater is executed.
At this time, the c:\ProgramData folder does not have a subfolder named <Company>.
Next, the background process executes “AAA_BBBBB-CCC_Updater.exe /justcheck” to see if updates are available. This returns a result code of 0, indicating that updates are available. The ProgramData folder now has the following structure.
ProgramData
<Company>
AAA_BBBBB-CCC
updates
AAA_BBBBB_CC.aiu (this is a copy of AAA_BBBBB_CCC_Updater_XX.txt)
Next, the background process executes “AAA_BBBBB-CCC_Updater.exe /justcheck -installready” to see if the update has been downloaded. This returns a result code of 0xE0000011, indicating that the update has not yet been downloaded. At this time there is no change to the ProgramData folder structure.
Next, the background process executes “AAA_BBBBB-CCC_Updater.exe /silentall –nofreqcheck
–justdownload” to download the update. This returns a result code of 0, indicating that the download is in progress. Once the download completes, the ProgramData folder now has the following structure.
ProgramData
<Company>
AAA_BBBBB-CCC
updates
AAA_BBBBB_CC.aiu (this is a copy of AAA_BBBBB_CCC_Updater_XX.txt)
AAA_BBBBB-CCC v1.1.0
AAA_BBBBB-CCC_setup_v1.1.0.exe
The next time through the background process periodic loop, “AAA_BBBBB-CCC_Updater.exe /justcheck” returns a 0 indicating that updates are available, and “AAA_BBBBB-CCC_Updater.exe /justcheck -installready” returns a 0 indicating that the update has already been downloaded.
Next, the user presses the button to run the downloaded installer. This installs AAA_BBBBB-CCC v1.1.0. The AAA_BBBBB-CCC_Updater.ini contains these 2 lines in particular
- DownloadsFolder=C:\ProgramData\<Company>\AAA_BBBBB-CCC\updates\
- URL=
https://www.server.com/AAA_Updates/AAA_ ... pdater.txt
By pointing the URL to AAA_BBBBB_CCC_Updater.txt, the ini file is set up so that it will download and install version 1.2.0 when the updater is executed.
So far everything is fine, but the problem is about to occur.
The next time the background process runs “AAA_BBBBB-CCC_Updater.exe /justcheck” to see if updates are available, it returns a code of 0xE0000001, indicating that no updates are available, and the AAA_BBBBB_CC.aiu file within the ProgramData folder has not changed. This behavior does not seem to be correct, as the 1.2.0 update is definitely available.
From this point in time, there are 2 separate tests that I performed.
1. Directly execute AAA_BBBBB-CCC_Updater.exe. It also tells me that the software is up to date.
2. Delete the AAA_BBBBB_CC.aiu from the ProgramData folder. With this file deleted, I can either run the updater directly or let my background process check for updates. In either case, the software detects that updates are available (the 1.2.0 version of the .aiu file is downloaded to ProgramData) and downloads them to folder AAA_BBBBB-CCC v1.2.0.
Also, if I go back to the start of the test where I have 1.1.0 installed and the ini file points to AAA_BBBBB_CCC_Updater_XX.txt, and then I directly execute the installed updater, it will download and install v1.1.0. Now if I execute the 1.1.0 updater (ini file points to AAA_BBBBB_CCC_Updater.txt, which should force a download of 1.2.0), again it says that no updates are available. The same is true of using the command line /justcheck option.
So ultimately, why is it that the 1.2.0 update is not detected unless the .aiu file is deleted from ProgramData.