Kaju self-updater talk (v.2.x)

  1. ‹ Older
  2. 8 months ago

    Kem T

    7 Nov 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    I just tested tonight with our existing system and had no issue. Is anyone else seeing something different?

  3. Douglas H

    7 Nov 2019 Testers, Xojo Pro

    So far I've done a few apps without issue. Code signed and notarized (via App Wrapper), and still the Kaju updates worked great. In my tests so far, the apps were not being app translocated. Perhaps that is the key here and the issue would be if the app had been translocated.

    I do have one app with bundled helper apps, and as soon as I sign and notarize the helper apps don't work. But the update still does. So I'm doing something wrong in my wrapping. But that is for another thread. So far it looks like Kaju is working as designed.

    (And off-topic, I tried putting the helper apps in Helpers or in MacOS but I'm still doing something wrong -- unrelated to Kaju.)

  4. Richard G

    9 Nov 2019 Testers Atlanta, GA

    Regarding the notarization of Zip files for Kaju, I'm just about to release an upgrade to my app that will include Kaju for the first time. so when I do my next app update, what would the projected workflow be for the update zip file?

    Codesign app.
    Notarize the app?
    Notarize the zip file but attach previous receipt?

    I do have Sam's App Wrapper.

    Thanks

  5. 7 months ago

    Thomas R

    19 Nov 2019 Testers, Xojo Pro Berlin, Germany

    Hi,

    are there any known problems with Xojo 2019 R1.1 on Windows 10? Update process runs fine (Zip file is downloaded and decompressed, files moved to "<foldername> - decompressed") until user clicks on "Quit & Install", then nothing happens.

    Method "StartUpdate" is the last thing executed - UpdateInitiater/Deconstructor is not executed and so the UpdateInitiater/RunScript is never called...

    Any ideas?

  6. Tim P

    19 Nov 2019 Testers, Xojo Pro Rochester, NY

    From the Readme:

    Important: Kaju does its magic by launching a command-line script when the UpdateInitiater gets set to Nil, which should happen when the app quits. Unfortunately, that's not always true so you should force the issue by inserting App.UpdateInitiater = Nil into your App.Close event.

  7. Thomas R

    19 Nov 2019 Testers, Xojo Pro Berlin, Germany

    Hi Tim,

    thanks for the reply, but thats not the point - as I wrote the update process is running fine (UpdatewIndow is shown, zip file is downloaded and decompressed and files moved) until the last steps (RunScript in Class UpdateIntiater), which is not executed on Windows 10...

  8. Kem T

    19 Nov 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    Are you saying that you added that code to the Close event as specified in the Read Me that Tim highlighted, and it still isn't working?

  9. Thomas R

    19 Nov 2019 Testers, Xojo Pro Berlin, Germany

    Sorry, Tim and Kem - its my fault. The line was commented out - must have happend while testing. Since updates worked fine on Mac I was searching for reasons why the won't work on Windows (except writeprotection in "program files" folder).
    After uncommenting the RunScript is executed, as expected...

  10. Edited 7 months ago

    Hello Kem,

    I did send a message via XOJO forum but I guess that did not get trough.

    While seeing the limitations on windows and searching little bit about elevated privileges I found those Link here

    In case the page does not work anymore the code was here :

    ::::::::::::::::::::::::::::::::::::::::::::
    :: Elevate.cmd - Version 4
    :: Automatically check & get admin rights
    :: see "https://stackoverflow.com/a/12264592/1016343" for description
    ::::::::::::::::::::::::::::::::::::::::::::
     @echo off
     CLS
     ECHO.
     ECHO =============================
     ECHO Running Admin shell
     ECHO =============================
    
    :init
     setlocal DisableDelayedExpansion
     set cmdInvoke=1
     set winSysFolder=System32
     set "batchPath=%~0"
     for %%k in (%0) do set batchName=%%~nk
     set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
     setlocal EnableDelayedExpansion
    
    :checkPrivileges
      NET FILE 1>NUL 2>NUL
      if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
    
    :getPrivileges
      if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
      ECHO.
      ECHO **************************************
      ECHO Invoking UAC for Privilege Escalation
      ECHO **************************************
    
      ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
      ECHO args = "ELEV " >> "%vbsGetPrivileges%"
      ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
      ECHO args = args ^& strArg ^& " "  >> "%vbsGetPrivileges%"
      ECHO Next >> "%vbsGetPrivileges%"
    
      if '%cmdInvoke%'=='1' goto InvokeCmd 
    
      ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
      goto ExecElevation
    
    :InvokeCmd
      ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
      ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
    
    :ExecElevation
     "%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
     exit /B
    
    :gotPrivileges
     setlocal & cd /d %~dp0
     if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul  &  shift /1)
    
     ::::::::::::::::::::::::::::
     ::START
     ::::::::::::::::::::::::::::
     REM Run shell as admin (example) - put here code as you like
     ECHO %batchName% Arguments: P1=%1 P2=%2 P3=%3 P4=%4 P5=%5 P6=%6 P7=%7 P8=%8 P9=%9
     cmd /k

    and in the description it was saying :

    The script takes advantage of the fact that NET FILE requires administrator privilege and returns errorlevel 1 if you don't have it. The elevation is achieved by creating a script which re-launches the batch file to obtain privileges. This causes Windows to present the UAC dialog and asks you for the administrator account and password.
    I have tested it with Windows 7, 8, 8.1, 10 and with Windows XP - it works fine for all. The advantage is, after the start point you can place anything that requires system administrator privileges, for example, if you intend to re-install and re-run a Windows service for debugging purposes (assumed that mypackage.msi is a service installer package):

    Do you think that could be added somehow in Kaju and have it work in Windows ?

    Thanks again.

  11. Kem T

    19 Nov 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    Possibly, but it's not a priority for me. Feel free to do a pull request off of the develop branch and I'll consider it.

  12. 5 months ago

    Walter P

    Feb 7 Testers, Xojo Pro

    Kaju has stopped working on Windows after a failed update. Kaju displayed an error message about the update failing because the file appeared to be corrupt (which it was, that time, because I'd erroneously pointed Windows at the macOS binary). Since then, it's doing nothing. There should supposedly be log files and/or temp files being generated, but I don't see anything in the application directory or the AppData directory (where the Kaju preferences file is located).

    Any hints? Anybody?

  13. Walter P

    Feb 9 Testers, Xojo Pro

    Figured it out. To nobody's surprise, I'm sure, it was due to another stupid error on my part (when I fixed the error of pointing the Windows update to the macOS binary, I should have changed everything to 64-bit Windows but instead had one thing as just Windows rather than 64-bit Windows).

  14. 4 months ago

    Frank S

    Feb 19 Australia

    I was testing out the Kaju self-updater for my app today. On Mac, all went smoothly as expected. However, on Windows (a 64-bit to 64-bit update), the update failed on installation. I am hoping someone knowledgeable here might be able to help point me in the right direction as to figuring out what's going wrong.

    1. I open my app with "run as administrator", so that Kaju has permissions to write to the Programs folder.
    2. Kaju detects an update is available
    3. I click download, and it downloads ok
    4. I click quit & install

    After some processing, command prompt opens and there is an error saying "the file C:\Program Files\MAK95\MAK95.exe could not be located. Check that you have the correct name..."

    When I look in C:\Program Files\MAK95, the main executable MAK95.exe indeed is missing. There is a new folder C:\Program Files\MAK95\MAK95.exe-20201902214544 which contains only the original MAK95.exe file.

    I have included a truncated version of the generated error log below (as it's very long), but hopefully I've left enough of the program flow for you to see what is happening. The problem seems to occur at the bottom, where it says "File creation error - The requested operation cannot be performed on a file with a user-mapped section open." and "C:\Program Files\MAK95\MAK95.exe-20201902214544\MAK95.exe - Access is denied."

    The code used in Kaju is way above my skill level, so any help would be greatly appreciated!

    Thanks,
    Frank

    "STARTED ON 2020-19-02 21:45:44" 
    "Copying items to backup C:\Program Files\MAK95\MAK95.exe-20201902214544" 
    "Looking for item C:\Program Files\MAK95\cef.pak" 
    "...found, copying" 
            1 file(s) copied.
    "...confirmed" 
    
    [... more files here ...]
    
    "Looking for item C:\Program Files\MAK95\locales" 
    "...found, copying" 
    C:\Program Files\MAK95\locales\am.pak
    C:\Program Files\MAK95\locales\ar.pak
    
    [... more files here ...]
    
           53 file(s) copied.
    "...confirmed" 
    "Looking for item C:\Program Files\MAK95\MAK95 Libs" 
    "...found, copying" 
    C:\Program Files\MAK95\MAK95 Libs\Appearance Pakx64.dll
    C:\Program Files\MAK95\MAK95 Libs\Browser Pluginx64.dll
    
    [... more files here ...]
    
            9 file(s) copied.
    "...confirmed" 
    "Looking for item C:\Program Files\MAK95\MAK95 Resources" 
    "...found, copying" 
    C:\Program Files\MAK95\MAK95 Resources\1_person_cheering.mp3
    C:\Program Files\MAK95\MAK95 Resources\ANZCALogoMask.png
    
    [... more files here ...]
    
           58 file(s) copied.
    "...confirmed" 
    "Looking for item C:\Program Files\MAK95\msvcp120.dll" 
    "...found, copying" 
            1 file(s) copied.
    [... more files here ...]
    
    "Looking for item C:\Program Files\MAK95\swiftshader" 
    "...found, copying" 
    C:\Program Files\MAK95\swiftshader\libEGL.dll
    C:\Program Files\MAK95\swiftshader\libGLESv2.dll
            2 file(s) copied.
    "...confirmed" 
    "Looking for item C:\Program Files\MAK95\v8_context_snapshot.bin" 
    "...found, copying" 
            1 file(s) copied.
    "...confirmed" 
    
    [... more files here ...]
    
    "Moving the executable MAK95.exe to backup" 
            1 file(s) moved.
    "...confirmed" 
    "All items moved to backup" 
    "Copying files from C:\Program Files\MAK95\MAK95- decompressed\MAK95 to folder C:\Program Files\MAK95" 
    C:\Program Files\MAK95\MAK95- decompressed\MAK95\cef.pak
    File creation error - The requested operation cannot be performed on a file with a user-mapped section open.
    
    "...confirmed" 
    "Removing backup" 
    C:\Program Files\MAK95\MAK95.exe-20201902214544\MAK95.exe - Access is denied.
    "Removing decompressed folder" 
    "Launching new app" 
    "Removing temp folder" 
  15. Kem T

    Feb 19 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    It sounds like something is keeping a file open. Are you certain your app is actually quitting?

  16. Rick A

    Feb 19 Testers, Xojo Pro (Brazil. UTC-3:00)

    Not sure if the case, but... When you "insert" some .EXE (move, copy...) into some systems with active antivirus, they can scan such files and those files will become "busy" during this time, with file handles in use at the antivirus part. The solution for such cases probably is "try again later" when the antivirus release it.

  17. Kem T

    Feb 19 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    So perhaps some retry code with a delay in the copy script?

  18. Frank S

    Feb 19 Australia

    Thanks Kem and Rick for the replies. Sorry for my delayed response. Firstly, Kem, thanks so much for making Kaju freely available, it is extremely generous of you!

    @Kem T It sounds like something is keeping a file open. Are you certain your app is actually quitting?

    From the scripting logic in the KajuUpdateWindow.HandleOKButton method, if CurrentStage = Stage.WaitingToQuit, then it should quit. But what is the best way to check this actually happens?

    @Rick A Not sure if the case, but... When you "insert" some .EXE (move, copy...) into some systems with active antivirus, they can scan such files and those files will become "busy" during this time, with file handles in use at the antivirus part. The solution for such cases probably is "try again later" when the antivirus release it.

    I haven't installed any anti-virus program. I should have only the in built Windows Security that comes with Windows 10. Would you know if that might cause a problem?

    This is the testing I've done so far. Because I have manipulated the Kaju code a bit to incorporate it into my app - and potentially I screwed something up! - I thought I should test with an unadulterated app. So I built a Windows 64 bit version of the Update Test App (v1.0.0) on my Mac. It built ok - though it came up with the message "The kaju CLI is not available. Build it first." Would that cause any issues? The Prepare Kaju script looks like it just creates the test files to upload.

    I copied the built Kaju Update Test folder into the Program Files folder on my Windows 10 virtual machine and ran it. The available updates are detected and I click Download then Quit & Install. The same error occurs when Command Prompt is open saying "Could not locate C:\Program Files\Kaju Update Test\Kaju Update Test.exe".

    The Update log is similar, except that this time there were a lot of files not found, eg

    "Looking for item C:\Program Files\Kaju Update Test\am.pak" 
    "...not found as file, trying as directory" 
    "...NOT FOUND!" 

    Again, the log ended with these errors

    "All items moved to backup" 
    "Copying files from C:\Program Files\Kaju Update Test\New Kaju Update Test- decompressed\Kaju Update Test to folder C:\Program Files\Kaju Update Test" 
    C:\Program Files\Kaju Update Test\New Kaju Update Test- decompressed\Kaju Update Test\am.pak
    C:\Program Files\Kaju Update Test\New Kaju Update Test- decompressed\Kaju Update Test\ar.pak
    C:\Program Files\Kaju Update Test\New Kaju Update Test- decompressed\Kaju Update Test\bg.pak
    C:\Program Files\Kaju Update Test\New Kaju Update Test- decompressed\Kaju Update Test\bn.pak
    C:\Program Files\Kaju Update Test\New Kaju Update Test- decompressed\Kaju Update Test\ca.pak
    C:\Program Files\Kaju Update Test\New Kaju Update Test- decompressed\Kaju Update Test\cef.pak
    File creation error - The requested operation cannot be performed on a file with a user-mapped section open.
    
    "...confirmed" 
    "Removing backup" 
    C:\Program Files\Kaju Update Test\Kaju Update Test.exe-20202002152356\Kaju Update Test.exe - Access is denied.
    "Removing decompressed folder" 
    "Launching new app" 
    "Removing temp folder" 

    This raises a couple more questions for me:

    1. In my app, for Kaju to work I need to open it with "run as administrator" otherwise it fails the Kaju.IsWriteableRecursive( executable.Parent ) check in UpdateChecker.PreCheck. But with Kaju Update Test, it worked when I opened it normally, not as administrator. My app was installed using InnoSetup, while Kaju Update Test I just copy & pasted into the Program Files folder. Is this difference in behaviour explainable, and if so, how do I set my app up so that Kaju works without having to run as administrator?
    2. Why would the update logs be different, with all the files in my app being found and copied, but for the Kaju Update Test, most files were not found? Does this help suggest a cause?

    Next I will test the Kaju Update Test on a real Windows laptop, to see if my virtual machine is causing a problem....

  19. Frank S

    Feb 21 Australia

    To follow up:

    I tested my app on a real Windows 10 laptop and the Kaju Updater function worked without a hitch :) Repeated testing on my Windows 10 virtual machine consistently failed with the "requested operation cannot be performed on a file with a user-mapped section open" error. So I am going to put it down to an issue with running it on a virtual machine. Fortunately, my users shouldn't have to do that as they can use the native Mac version.

    Cheers,
    Frank

  20. Frank S

    Feb 22 Australia

    Unfortunately I celebrated too soon. On 2nd testing on my Windows 10 laptop, the update failed with the same error. On 3rd test it worked!

    I think I will have to try to change the workflow so that it downloads an InnoSetup installer instead that overwrites the previous version. Earlier in this thread some people have suggested this workaround when they have had similar problems. Would anyone have a working version that demonstrates how to do that?

    Thanks,
    Frank

  21. @Frank S I think I will have to try to change the workflow so that it downloads an InnoSetup installer instead that overwrites the previous version. Earlier in this thread some people have suggested this workaround when they have had similar problems. Would anyone have a working version that demonstrates how to do that?

    The link to the project is a demo of what I picked up from the forum a long time ago and then made some minor fixes. The bulk is not my work...
    https://1drv.ms/u/s!AvNnNHA7In4qqNtozraoOxVv2scjNQ?e=anbyKX
    I use this for both MacOS and Windows and works ok. I am using this for a deployed application for the last 4 years with at least 15 updates over time. Limitations with this implementation:

    • it uses HTTP and there might be problems with certain hosting domains security requirements
    • It downloads dmg and .exe files and I had to change hosting company as my original company identified innosetup .exe as malware and it got blocked/removed automatically.
    • There is no protection at all against downloading a modified file and downloading malware. It has no security whatsoever which is my main reason of switching to Kaju sooner or later.

    I just cut and paste this from my main app so not sure if I missed out something.

    Long term I still want to switch to Kaju because it is a much neater and more capable option, but on the other hand I don't have the confidence yet to deploy it for an application where the users are having poor computer literacy and are 2 hours flying from my place. If there is a problem, I have no way of getting help identifying the problem. At the moment I am in the mood of "if ain't broke, don't touch it". But I know it will break sooner or later.

    To me this is a work around and not a long term fix.

  22. Newer ›

or Sign Up to reply!