Install4j uninstall other program - install4j

The examples I have found of Install4j are simple wizard generated and don't show more complex logic. I need some help to do the following in Install4j v6.
Desired flow
Display the initial welcome screen
check for other program being installed in Windows
if other program is installed
Display message to user with confirmation to remove the other program
If confirmed, run the Windows Uninstaller for the other program
If not confirmed, exit the installer
I found question 27497335 which describes how to search the Windows Registry. Also question 10282814 which describes how to run a Windows uninstall.
I'm unsure of how to use these in my install to achieve the above flow.

To organize screen flow, use screen groups and set the condition expression on the screen groups or on single screens.
To see an example, add a "standalone updater" application on the "Installer->Screens & Actions" step. It uses screen groups with condition expressions to behave in different ways depending on whether the installation is up to date or not.

Related

Is it possible to passively install an .EXE but still show the GUI using Powershell?

Pretty much what the title says, is it possible to passively/silently install an .EXE using Powershell but still have the installer GUI show? I'd want the next's "clicked" automatically but would still like the GUI to be shown as sort of a progress indicator.
UPDATE: There is a Powershell module for Windows Installer. It can help to run msiexec.exe equivalent commands in easier fashion than to deal with Powershell's quirks.
MSI?: If this is an MSI inside an EXE wrapper, then the below will generally work. If it is just a normal EXE file you should repackage as Painter answers - or run it silently with the correct switches - if possible.
MSI Extraction: Extract MSI from EXE.
Repackaging: Last resort is to convert EXE to MSI using capture tools.
Quick summary on repackaging (convert setup.exe to MSI - more links: at bottom)
How to run an installation in /silent mode with adjusted settings
Suggestion: I would suggest this command line based on what you wrote (basic UI with modal box displayed at completion & hide the cancel button during installation):
msiexec.exe /I "setup.msi" /qb+!
Sample progress dialog with hidden cancel button:
Keystrokes: It sounds like you want the whole GUI wizard to show up with all the buttons "auto-magically" clicked? That is hard. Crazy tools such as AutoIt - the ones that push keystrokes to application windows - could do it, but that is about as reliable as your average house of cards. There are always error sources in such duct-tape approaches.
Silence!: I assume you know you can suppress the whole GUI for an MSI with standard command line switches for msiexec.exe? You can go for completely silent GUI or exactly a progress bar like you describe and many other combinations. You can even hide the cancel button. Nifty.
UILevel: MSI supports various "UILevels" - the installation can be varying degrees of interactivity from totally silent to fully interactive. There are 4 basic levels and various "modifiers" (show completion dialog or not). Here is an answer on the different UILevels in practice: Uninstall from Control Panel is different from Remove from .msi
Examples: Here are some further example command lines:
Totally silent, no GUI at all:
msiexec.exe /i "setup.msi" /qn
Basic GUI with no modal dialog boxes and hidden cancel button:
msiexec.exe /i "setup.msi" /qb-!
No GUI except a modal dialog box displayed at the end:
msiexec.exe /i "setup.msi" /qn+
Note: There are several further combinations depending on how you configure things with the 4 different levels of GUI, the modal dialog at the end or not, and finally hide or show the cancel button.
Advanced: Beyond the normal use of msiexec.exe you can suppress the whole GUI of an MSI programmatically via the MSI Win32 API and instead handle the progress messages yourself.
Handling Progress Messages Using MsiSetExternalUI (C++ sample code, also on github.com)
Serverfault answer on external MSI GUI
WiX Bundles: This is the approach the WiX toolkit uses to deliver its own, modern GUI for bundles. Advanced Installer and Installshield and others have similar concepts. The integration with Windows Installer is all based on these API-calls.
Links:
Tip: User Interface Levels for MSI Installations
Uninstall from Control Panel is different from Remove from .msi
Run MsiExec from PowerShell and get Return Code
Repackaging:
Create MSI from extracted setup files (and another answer in the same post)
Capturing all changes during an application install on Windows
http://blog.deploymentengineering.com/2004/12/chriss-rant-about-repackaging.html
http://www.installsite.org/pages/en/msi/admins.htm
What your describing is the difference between fully silent (no ui) and non-interactive (has a UI but the user doesn't need to interact with it). If it is a best practices following MSI then what #SteinAsmul described is your ticket.
If it's a poorly written EXE based installer that didn't consider this use case and doesn't support it then you would have to "repackage" the installer (reverse engineer / rewrite ) the installer into an MSI so that it is supported

Can you program a powershell script to press next in an install wizard?

I'd like to create a Powershell script to press the next button in an installation wizard.
I'm troubleshooting a script that a client wrote to help them automate the process of installing software. This script can allegedly fully install any program (with some small amount of customization from program to program).
Now I've gotten it to work to a point where it launches the install wizard, but then nothing happens. Their problem only happens further down the install process, but I can't seem to figure out why the first part of it being able to press next doesn't work.
I can provide code if necessary.
What line of code I should look for in the script that could make the script push the "next" and/or "continue" buttons?
Can you? Probably.
Powershell has access to .Net API and even native Windows API, so you could go low-level enough to enumerate windows in the installer window, find the window labeled 'Next' and send a pair of mouseDown, mouseUp events to the button.
Should you? Probably not.
As mentioned in comments, any good installer system supports some method of installing silently. MSI, if I recall correctly, has a way of recording manual steps performed by a user and store them in a Response File. Then you may pass the .rsp file in later executions of the installer.
See other answers:
How to make better use of msi files

Start an application at system start without login

We have a new server running and we got some new programs doing import routines. So far so good... But there is one program that is put into autostart folder. So it doesn't run until admin logs in and it stops if we logout.
I'd like to put this one into a seperate session so it may work without any interaction by simply starting it with the task scheduler at startup. Is this the right way to do this? Is it safe if I log in later and log out?
Many thanks!
Edit: The applications shows as a symbol in the task bar if running, it can be configured by this. Anything I must know about this if I change?
Edit: It is not my application, I cannot rewrite it as a service.
I successfully added the application by using task schelduler on startup. Login and logout will not quit the application but no symbol is shown. Please add details to my side questions and I'll mark your answer as the accepted one.
Edit: Ended up using this one. If I have to configure, I stop the application in task manager and start it again by link. After that I quit the application and restart it by task scheduler manual start.
You need to run your program as a Windows Service. One way of doing it is using the sc.exe program:
> sc create <new_service_name> binPath= "c:\myapp\myapp.exe"
You can read about it here.
You need to separate your application in two.
To allow it to run without a user session, you need a windows service. That should handle all the background stuff. You can then register the service and set it to start when the system starts.
To allow it to have a UI, and show up in the notification area, you need a windows application. This will be in autostart as usual, and will communicate with the service - for example, over named pipes.
While it is still (barely) possible to run an UI application without a user session, it's only maintained for backwards compatibility, and already shows a lot of problems. It will likely be removed altogether in the future, because it breaks quite a few contracts. Do not rely on hacks like this.
I also used the task scheduler to create the application at system startup. It should be noted that if you want to use for mining, you have to disable an option in "settings" where it says that if the application lasts more than three days in a row it will end.
It really works wonderfully!
it is a old question but I recently solved in another way...
(before I was using a scheduled-task for startup but this gave me diverse problems with lots software...)
Some programs also for diverse reasons must be run at a user level... or even inside a specific user session...
So the best way I found was to use a tool like Sysinternal/Autoruns to program the auto-logon to a specific user (it is a registry setting)... and in the startup-folder of that user (or any other "autorun/autolaunch" task)... run a script that first locks the screen... and next runs the other intended programs... that will run under that user profile...
so you can choose a standard user or a administrator... or even launch programs from a standard user in adminsitrator mode...
I hope will help...
This "hack" solved me many problems with startup apps...
I could not get the "sc create" command to work. Instead I manually edited the registry using regedit. I added a new key in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services.
I used the following page to figure out required parameters and their values. Note that the names do not map.
https://learn.microsoft.com/en-us/windows-hardware/drivers/install/inf-addservice-directive
Old question, but for anyone that stumbles here. Use srvany to set the program as a custom service.
Note that when you do this with for example dropbox, googledrive, etc., you will need stop the service, then open the program normally to make changes like password, updates, etc.
below is a well enough intro.
https://www.iceflatline.com/2015/12/run-a-windows-application-as-a-service-with-srvany/
Download the tool kit here
https://www.microsoft.com/en-us/download/details.aspx?id=17657
Convert user application to Service and Register it using Regsvr32 or installutil.exe. It will start the service using SYSTEM user account. Which is a high privilege account.
Note : You can`t run any Window based application. Even a Message only window.

Suggestions for a bad PowerShell Script

We have a legacy server service running on a Windows 7 desktop that keeps crashing with a popup window reporting a memory error. The popup stops all processing on the machine. Once the "OK" button is clicked on the popup the system recovers and moves on. The root problem appears to be inside a compiled DLL that the application uses.
This popup usually happens between 9pm and 11pm every couple days.
It happens when no one is signed into the PC, so the popup displays in front of the CTRL+ALT+Delete message for signing in.
I can click OK and it continues processing, signing into the computer.
CHALLENGE:
This is a legacy application that will be replaced when budget allows (maybe next Summer) so there is no budget for upgrade or paying a consultant to fix the root problem.
All we need to do is click the OK button when the "Application Popup" event is thrown (logged in the Event Manager)
I know that it would be WRONG to write a script to satisfy the popup. Fixing the root cause is the CORRECT action.. but we have no support to spend money at this time. And since it's a compiled DLL, we can't fix the code.
Is there a PowerShell script that could:
Watch for a specific event "Application Popup" and if it occurs simulate pressing the ENTER key?
Run in the background, signed out of a user account.
If PowerShell isn't the answer, is there a better macro or script tool to get us by?
I know it's "bad practice" but we just need to get along until we get some budget dollars.
Powershell probably isn't the best answer in this case. I'd suggest using something like AutoIt (the WinWaitActive function would be useful in your case).
I have used AutoIt in the past and have found it very useful for Windows GUI automation.

Does install4j provide a *Completely* unattended auto update?

We are currently evaluating install4j and things are going pretty well, however I have a question about auto-update.
Currently I see options and documentation around 3 options for auto-update and the third one (no version check) seems
to be the closest to what we need. However it sounds as though it still prompts the user to actually start the download/install. Is there
any way to get around this? We are targeting our software as a service on many windows boxes in a server room, so there isn't a user
to click continue for that last step. I believe we can roll our own service to monitor for upgrades that will do a command line
install with an answers file to prevent prompting, but I'd love to know if I missed something that would allow me to utilize
install4j's auto-update.
When you go to Installer->Screens & Actions, click on the "Add" button and choose "Add application", you can choose from a number of pre-defined templates. However, they are just templates and after adding them you can change them completely.
If the updater should be automatic but still show a progress dialog, you can just set the "Default execution mode" property of the updater application to "Unattended mode with progress dialog". In that case, no screens will be shown at all.