zhiyangchen
Level 6

how to display message in silent installation?

Hi everyone,

Do you know how to display message in silent mode? I try to use custom code but it doesn't work.

System.out.println("Show message");
Labels (1)
0 Kudos
4 Replies
purcellk24
Level 7

Silent mode = SILENT. You won't see any messages. Best bet is to write them to a log file so you can review after the installation is complete.
0 Kudos
daniel_armbrust
Level 2

zhiyangchen wrote:
Hi everyone,

Do you know how to display message in silent mode? I try to use custom code but it doesn't work.

System.out.println("Show message");



Why yes, yes you can. Silent mode has a rather silly design limitation that they don't give you a way to print a failure message when things go wrong.

Here is how you can overcome that:


import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.PrintStream;

import com.zerog.ia.api.pub.CustomCodeAction;
import com.zerog.ia.api.pub.FatalInstallException;
import com.zerog.ia.api.pub.InstallException;
import com.zerog.ia.api.pub.InstallerProxy;
import com.zerog.ia.api.pub.UninstallerProxy;

/**
* Simple Install Anywhere Custom code task to stop the installer and print an
* error message. Useful for silent installs.
*
* Prints the value of the variable FAIL_MESSAGE before it stops the installer.
*
* @author Dan Armbrust
*/
public class Fail extends CustomCodeAction
{

@Override
public String getInstallStatusMessage()
{
return "Failing";
}

@Override
public String getUninstallStatusMessage()
{
// noop
return null;
}

@Override
public void install(InstallerProxy ip) throws InstallException
{
String failMessage = ip.substitute("$FAIL_MESSAGE$");

// install anywhere redirects these somewhere - put it back.
System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream(java.io.FileDescriptor.out), 128),
true));

System.out.println("INSTALL FAILURE: " + failMessage);
System.exit(1);
// should be unreachable, but just in case...
throw new FatalInstallException("INSTALL FAILURE: " + failMessage);

}

@Override
public void uninstall(UninstallerProxy arg0) throws InstallException
{
// noop
}
}


If at any point in an install, you want to exit the (silent) install, and print a message to a user, simply put the message in the variable FAIL_MESSAGE and then execute this custom code.
0 Kudos
pv7721
Level 20

Well, silent mode does not have a silly limitation, but it has been designed to run in a failure-free mode (i.e. the silent mode has been designed, I think, in order to facilitate multiple scale, automatic deployments, which should happen without any end-user interaction (i.e. once the setup has been launched). That is why this whole installation mode has been conceived with the idea that installation won't fail (and well, if it does fail, then the end user will see that the application hasn't been fully installed and will proceed to a manual installation). I think you defeat the whole purpose of the silent installation if you start working around it and try to get messages displayed etc.
0 Kudos
elangovv
Level 2

First of all to add with others, a silent installer is always a silent installer. You cant change its functionality. But you can break it if required.

The following is the solution i identified when i had a task to address the same issue. The solution is as follows.


  • Add action Modify Text File and Select New File. example MessageDialog.CMD
  • Add the Following contents into the file.
    @echo OFF
    echo Your Message Goes Here
    pause
    exit

  • Add action Execute Script/Batch File. Add the following line into that.
    start MessageDialog.CMD

  • Add Action Delete File and select Existing. Give the file name MessageDialog.CMD


We can replace the PAUSE command with SLEEP so that it wont prompt the user, rather it will be visible for some time and it will disappear automatically.

Note: This works fine with windows ONLY.
0 Kudos