ktekinay / Kaju

Xojo code for implementing self-updating apps
MIT License
61 stars 33 forks source link

Update check doesn't work on Windows unless app is run as Administrator #20

Open jmadren opened 4 years ago

jmadren commented 4 years ago

Hi Kem,

I had everything working great until I tried in on an "installed" version of my app (installed in the normal program files). When the app runs from there, it never shows that an update is available. But if I "run as administrator", then it works (update is detected/found, update/install process runs).

Also, when it does run (as Administrator), the install process is failing to completely remove the backup. Log files says "Access is denied" when trying to delete the executable. All other files in backup are removed successfully, only fails on the executable (and therefore the backup folder remains as well). This does not occur if running the app from somewhere besides the program files folder (like the Xojo build folder) - just like the update detection issue above.

I tried updating to the current release of Kaju (after fixing that same issue I reported before - "shZipper set to Synchronous mode instead of Asynchronous after copying classes from Admin app"), but get the same results. Both the no updates unless run as Administrator, and failing to delete backup when it does run.

This was tested with Windows 10 on two different computers.

Thanks, Jay

jmadren commented 4 years ago

Ok, found the issue (for Update check not working). In Precheck it tests if the folder and files are writeable, which they are not for a non-administrator. Is there a way to work around this? I'm guessing it needs to initiate a UAC elevation, but only when it tries to install an update. All the prior update checking needs to work with the assumption that the application folder is not writeable (so write/download any needed files to the app data folder or something).

Thing is, I was checking ResultType in the ExecuteAsyncComplete event, but never got any result. Turns out that if Precheck fails, it sets the result but then returns false. I didn't trace everything out, but apparently this is prevents ExecuteAsyncComplete from firing, so I was not getting any ResultType.

stretch327 commented 1 year ago

I would think that for installed products, you would want to download the latest installer and that pre-check should just check if the temp directory is writable, download it there and the launch the new installer.