ApplicationLauncher.Callback notification on finishing Install4j installation - install4j

I am using autoupdate feature of install4J by using ApplicationLauncher.launchApplicationInProcess() API from my Java code.
This API has a parameter ApplicationLauncher.Callback. I thought this call-back method will be called when complete Installation process will finish.
But I observed that, this call back is not getting called when actual installation process (name of this process is same as setup file name) is completed.
Is there any callback mechanism to detect the status of installation?

There are two separate processes here:
The updater, which is what you call with ApplicationLauncher.launchApplicationInProcess()
The new installer, which is started downloaded and started by the updater.
The callback is called before the updater executes the installer, then the updater terminates itself. This sequence of events is required to avoid problems with locked or deleted files.
If you need to do something at the end of the installation, you have to place that logic in the installer.

Related

Build code in vscode using external http server

Our code building process is done via an http server which starts the build process after receiving a project uuid from the build command. Once the server starts the compilation, GCC compatible output can be fetched from it.
Note: only my extension is aware of the project uuid which is different per workspace.
AFAIU I can implement it by:
programmatically adding a task which will call a script with the correct workspace uuid. Is this possible?
Having my extension manage the build process. This seems to be far from supported.
Bottom line, I'm trying to avoid asking the user to add anything to the configuration files and I want to completely manage the build process.
Thanks!
As I didn't find a suitable only vscode solution I did the following:
Defined a helper script which I executed as the task. The helper script was respojnsible for the communication against the HTTP server.
I registered the task using vscode.workspace.registerTaskProvider API, and made sure to register it only after figuring out the UUID.
Then in the task itself I executed the helper script.
(A nice task register example can be found here: https://github.com/Microsoft/vscode-extension-samples/tree/master/task-provider-sample)

install4j: Unattended auto-update and relaunch at end

So I'm trying to build an auto-updater for my app. I've chosen the "Update downloader with silent version check". It's integrated with my launcher as well, like it can be seen in the first picture. I'd like if possible to remove the screen where the user is asked whether to launch the updater and just always execute it.
launcher integration
Screen to remove
My client would also like to have the auto-update process as unattended as possible. So it would need the following steps:
1) user starts launcher
2) auto-updater checks and finds new version
3) auto-updater downloads new version
4) auto-updater launches downloaded updater
5) auto-updater finishes and relaunches new version of the app
I've managed the first 4 steps but I can't manage to make it relaunch the app, or at least have an informative message saying that the user needs to relaunch it him/herself. I've added the Execute launcher action but it seems to either not launch or launch the previous version. Is there a tutorial or anything for this at it seems like my case is pretty standard? :(
Any help would be appreciated, as I've been struggling with this for a while.
Thanks
The background update functionality in install4j (since 7.0) is more suitable for your use case.
See
https://www.ej-technologies.com/products/install4j/whatsnew7.html
and search for "Background auto-update" to see screen shots.
To get started, add a "Background update downloader" application on the Installer->Screen & Actions step.
In the launcher wizard of a GUI launcher that should process scheduled update installers, go to the new "Auto-update integration" step and select the "Execute downloaded update installers at startup" check box. By default, the execution mode is set to "Unattended mode with progress dialog".
For services and command line launchers, the UpdateChecker API allows you to execute scheduled update installers programatically.
You can also execute the downloaded installer as soon as it's downloaded. The source file
samples/hello/gui/HelloGui.java
shows you how to interact with the background updater by using the API.

How can the auto updater wait for an event from the launcher executable?

I am using an updater application (without version check) in unattended mode, but I need the updater to wait for an event from the launcher executable before continuing to execute the installer.
The event will typically be a user confirmation that the downloaded installer can be executed. I would prefer that the launcher executable prompt the user to update, once it knows that the downloaded installer is ready.
Is there another way to solve the problem?
There is no such communication mechanism as of install4j 6.1.
I would recommend to change your updater application so that it does not execute the installer but just writes it to a particular directory. After it has finished you can check if an executable exists in the directory and ask if it should be executed. If the user confirms the update, you then invoke another custom installer application that only contains the "Run executable" action from the original updater template.

How to create a service for automatic update?

I've tried to create a service that calls the update application configured in the project. Therefore I used the "silent version check" template for the update process and modified the ServiceDemo.class from the sample to start the update application.
ApplicationLauncher.launchApplication("2529", null, true, null);
But everytime I tried to install or start the service manually or with the command line executor nothing happened.
With the following command line call the updater starts:
java -cp classes;.install4j\i4jruntime.jar install4j.sample.service.ServiceDemo
Is it necessary to add the i4jruntime.jar to the classpath or is it bundle with the exe-file? But I can't see anything like that for the greetings-example. Has anybody an opening for me how to create such a service?
I am using version 5.1.5.
Thanks in advance
Hardie
Generally, you cannot use a service to display a GUI. The updater would work if you run it in unattended more (with the -q flag).
To check what happens, redirect the output to a file ("Executable info->Redirection" in the launcher wizard). Also, the updater writes a log file to the temp directory that is deleted after successful completion. To keep the log file, start the updater with -Dinstall4j.keepLog=true.
You never have to add i4jruntime.jar to launchers that are generated by install4j. That JAR file is added automatically to the class path.

How to avoid application start after cancel auto update on startup?

Today I need help to deactivate the auto startup of the main application after I abort the update process. The update is triggert automatically during startup so I used the "silent version check" template. But I can't find any option to deactivate the automatic startup.
It is necessary to update the version if there is any newer then the installed one before starting the main application.
I am using version 5.1.5.
Thanks in advance
Hardie
If your requirements are more complex, you cannot use the automatic launcher integration. On the launcher integration tab of the updater, click on "Start integration wizard". The wizard will give you a code snippet that you can invoke in the main method of your application in order to start the updater.
Surround that code snippet with
if (UpdateChecker.getUpdateDescriptor(UPDATE_URL,
ApplicationDisplayMode.GUI).getPossibleUpdateEntry() != null) {
// code snippet from the integration wizard to launch the updater
}
so that the updater is only invoked if an update is available. Then, if you do not receive a call to prepareShutdown, you can display a warning and close the application.