Install4j: Silent updater exits on start - install4j

I am running my installer in silent mode (-q option).
After starting, the installer quits. The error.log shows the entry:
"The application is running. Please close instances and run this installer again".
However, there is no other instance of the installer running.
Note - The installer is launched in the Windows local system account.

I encountered the exact same issue with an updater installer being run in unattended (silent) mode and launched from a Windows service. I discovered that there were two reasons for the updater failing to complete:
The unattended mode installer was being invoked with arguments -q -wait 20 (these are the defaults when generating an updater application using the install4j UI). The -wait argument causes the installer to wait for running applications to close before progressing to the stage where the Welcome screen would normally be shown in an interactive install. It does not attempt to close them itself. If the applications don't disappear within 20 seconds, the installer exits at this early stage with the error.log message "The application is running. Please close instances and run this installer again". (In interactive mode the user would be shown a screen at this stage asking them to close the running applications.)
(Note: -wait only seems to check for the presence of application processes (user launched apps, UIs etc). Installed services that are running are not considered a blocker, probably because they are automatically stopped as part of the Install files action.)
I had already added actions later in my installer to close down the application processes before installing the update, but the -wait argument was not allowing it to progress that far. I removed the argument from the "Set installer arguments" action in the updater app and this allowed the installer to progress beyond the welcome phase.
The 'Check for running processes' action, using a Close strategy of 'Soft close immediately', failed to close any user-launched applications running (UI applications in my case) when the installer was launched from the Windows service. This in turn caused the unattended update to fail due to locking issues overwriting the installed files.
However using the Close strategy of 'Terminate immediately' did allow the service account to successfully kill the running applications and allowed the installation to complete.
I ended up using a sequence of "Stop a service", "Check for running processes (soft close)" (which works when the installer is run in interactive mode by a user), then "Check for running processes (Terminate immediately)" at the start of the Installation section to cover all bases.

Related

Stop restart loop in kiosk mode with crashing application

I have a Windows 10 LTSB 2016 machine set up in kiosk mode to run a single application. I followed the Powershell instructions at https://learn.microsoft.com/en-us/windows/configuration/kiosk-shelllauncher#configure-a-custom-shell-using-powershell to build the install script, it works well. In that script, I can set the behavior of the shell if the application crashes. I can restart the application, restart the PC, or shut down the PC.
In general, this is all good, but occasionally someone does something like edit a file that causes the application to instantly crash on starting. Because I have the script set to restart the application, this causes the shell to get stuck in a loop where the application is rapidly crashing and restarting. This fills my logs and is generally a poor UX for the end user.
I'd like to condition the behavior so the application only attempts to restart a limited number of times, then shuts down (or some other behavior). Is there any way to achieve this? Can the custom shell access a counter, or accept a return statement from the application (e.g. to differentiate between an intended application shutdown/restart vs an application crash)?

How do I (administrator) gracefully close a window process running in another user session using powershell on Windows 2008 R2 Remote Desktop Services

If I run the following command in my session...
(Get-Process -Id $pid).CloseMainWindow()
I am able to gracefully shut down a process (no modal windows or other popups arise).
If, however, the pid is in another user's session on the same machine (running RDS), the process does not close, and CloseMainWindow() returns FALSE (it returns TRUE if it's running in my own session). It also works if I run the powershell from the other user's session.
I specifically need a way to gracefully shut down the program as the program has a few important cleanup actions required to keep its database in order. So stop-process or process.kill() will not work.
After lengthy research, it does not seem possible to do this. There is, however, a solution which met at least some of my requirements.
You can create a Windows Scheduled Task which is triggered on session disconnect. This allows you to run a cleanup job as the user, rather than as the administrator, which allows programs to exit gracefully.
It has two major drawbacks....
It is called even if the user just has a minor network interruption (so you have to build a wait() function in the script to sleep for a bit and then check if it is still disconnected - not a clean solution.
It isn't called during a log-off event. For that you need to use a logoff script triggered by GPO.
Hope this helps someone in the future.

install4j windows service -- restart on failure option

I have a working install4j 6.1.3 service. Due to a 3rd party memory leak we want to be able to have our application exit and then have the service automatically restart itself on a regular basis. There is a checkbox on the install4j create services option screen "Restart on Failure" that says that it should restart the service unless the exit code is '0'.
The java application is calling System.exit(27).
We have also tried codes -1, 0 and 1.
The application exits, but the windows service does not auto restart.
Is there something more that needs to be configured for this to work, or a different way to exit the java application to get the service to automatically restart itself?

Test Automation tool not running via Windows Task Scheduler

Here is a general description of the issue which I cannot solve:
We have a WindowsServer 2008 R2 system that is used to running the install of our product(using powershell script), and then the Powershell script calls the .exe of our UI test automation tool (Ranorex).
The install of the product works fine, but the UI automation portion only runs if some is physically logged in via remote desktop.
If the remote desktop session is closed (but the programs continue to run..so user is technically logged in), the UI automation portion will NOT run.
The options I selected on the General tab of the job are:
-Run only when the user is logged in;
-Run with highest privileges;
Any ideas on from anyone who has had this issue and got it to work would be extremly helpful.
Thanks,
Eric
UI operations are usually in suspended state when a user is disconnected from an RDP session. Use a tool like VNC or equivalent where you have access to the main console for these UI operations to remain active.

Stopping the service and the babysited application before uninstalling

I have a service MyService.exe that is babysitting my application MyApp.exe, meaning it starts the application when this one crashes or whatever. Basically when the service is stopped the application is stopped (by the service) and when the service is started the application is started by the service.
In order to stop my service and by that my application when uninstalling I'm doing:
<ServiceControl Id='MyServiceControl' Name='MyServiceForTest' Start='install' Stop='uninstall' Remove='uninstall'/>
But when I want to uninstall everything I get the error message: "The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.". If I manually stop the service before running the uninstaller I don't get this msg as both my service and my application aren't then running anymore.
In the log file I noticed that this happens in InstallValidate and I get this message b/c of MyApp.exe being running.
I think what happens is: the uninstallers checks the running applications, it notices that the MyService.exe and MyApp.exe are both running, detects probably that the MyService.exe will be stopped by the uninstaller itself as instructed, but doesn't know about the MyApp.exe that this one will also be terminated once the service will be stopped so it will show the reboot-message.
I can't just close MyApp.exe from uninstaller b/c the service will restart it again.
How could I solve this problem so that the user won't need to reboot or to manually stop the service before doing an uninstall/upgrade? Also, I can't change MyService and MyApp code anymore so I will have to do this from the (un)installer only.
TIA,
Viv
I would expose a mechanism in your service in which your installer can instruct it to stand down and terminate the application. This way when Windows Installer costing looks for locked files it doesn't find any.