B4J Question B4J How to implement a self update for an exe ?

focus330

Member
Licensed User
Longtime User
Hi

I want to make in my app an automatic control of the release using FTP ( this is simple ) and then make the update of the app.
That means: control of a txt file with a release field, download the new app and substitution of the current one.
Can someone give me an idea ? Using jshell ? Creating a service ?

Thanks
 

behnam_tr

Active Member
Licensed User
Longtime User
you can download new file after check version and save it in dir.temp and close app

befor close you can run bat file or another b4j app for copying and replace newfile
from dir.temp to dir.app with 5 second or more dely

i do this with another b4j app that copying file

actualy copy opretion run after close mainapp + 5second

B4X:
Sub Download_onSucess (Path As String,Name As String,FileSize As Long)
 
    Log("download Finished.....")
 
    'save newfile in File.DirTemp
 
    fx.ShowExternalDocument(File.GetUri(File.DirTemp,"CopyTask.jar"))
  
   ExitApplication
 
 'CopyTask.jar  copy file with 5 second dely from temp do app folder and run newFile  
 

 
 
End Sub



second app instruction (none_ui App) ' copytask.jar

sub start

sleep (5000)

'copy file .....

end sub
 
Last edited:
Upvote 0

Magma

Expert
Licensed User
Longtime User
...Hi there - it is better having 2 exe....

First EXE will always check first for new version or every some days..
If found will download new version (extract/start install/replace/reboot)

If not will continue and shell the other exe (that will be the main app)
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Googled for "windows programmatically restart program" and found this.
Another one from Microsoft.
Just to say that eventually it could be done in a single exe:
- check&download
- rename
- restart

udg
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
For what it's worth if you are running your app as a service on windows you can use this wrapper to auto download and update your app.

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…