cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jdmaddison
Level 3

Running an EXE from Pre-Install

I am looking to run an EXE during the Pre-Install and check the return status. I found the following post with some answers:

> http://community.flexerasoftware.com/showthread.php?179568-Pre-isntall-requirement

However, I am new to the product and I don't know how to

> ... can do so by adding the file into INSTALLER_TEMP_DIR (installer temp directory) ...

I have gotten the install to run the EXE and return the expected error status, only I had to copy the EXE into the expected location before running the installation. Hopefully, I'm just missing an easy way to include that program and get it put into position on or before the Pre-Install. Any suggestions would be most appreciated.

Thanks,

jdmaddison
Minneapolis, MN
Labels (1)
0 Kudos
(6) Replies
UtsabKarmakar
Level 5 Flexeran
Level 5 Flexeran

Hi,

Keep the exe file in install.exe folder.
Use $INSTALLER_LAUNCH_DIR$ to get the path of the install.exe
Then execute the script that you want to run in pre-install like this :$INSTALLER_LAUNCH_DIR$\.exe to execute it
Then get the return status from the action and then proceed with the installation depending on the status.

Let me know if it helps

Thanks
Utsab Karmakar
0 Kudos
jdmaddison
Level 3

UtsabKarmakar wrote:

Keep the exe file in install.exe folder.


There's the catch-- I need to extract the program file needed to run from install.exe during the pre-install task. I need to be able to loop on prompting for input (from an InstallAnywhere panel) and then running the exe with that input, until the exe returns success or the installation is canceled.

Thanks,

jdmaddison
Minneapolis, MN
0 Kudos
DLBoyd151
Level 2

You can add the exe to your jar file and then use getResourceAsStream to write it out to the temp directory.

This is a simplified example...


public class MyCustomCodeClass extends CustomCodeAction {

public void install(InstallerProxy ip) throws InstallException {
File f = extractExecutable();
if(f != null && f.exists()) {
RunMyPreInstallApp(f.getAbsolutePath());
}
}

public File extractExecutable() {
File fileOut = null;
try {
InputStream in = MyCustomCodeClass.class.getResourceAsStream("MyPreInstallApp.exe");
fileOut = File.createTempFile("MyPreInstallApp", ".exe");

FileOutputStream out = new FileOutputStream(fileOut);
byte[] temp = new byte[32768];
int rc;
while((rc = in.read(temp)) > 0) {
out.write(temp, 0, rc);
}
in.close();
out.close();
fileOut.deleteOnExit();
} catch (FileNotFoundException e) {
System.out.println("FileNotFoundExection: " + e.getMessage());
} catch (IOException e) {
System.out.println("IOException: " + e.getMessage());
}
return fileOut;
}


public String RunMyPreInstallApp(String commandline) {
String result = "";

try {
if( !commandline.equals("") ) {
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(commandline);

InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);

String line;
while((line = br.readLine()) != null) {
result += line;
}
}
} catch (IOException e) {
e.printStackTrace();
result += "ERROR ";
}

if(DEBUG) {
System.out.println(commandline + " result: " + result);
}

return result;
}

}
0 Kudos
trehananirudh
Level 3

May be this is too late but this can be done in following steps -

1. Add action plugin: extract to file at pre-installation and extract required file from location $IA_PROJECT_DIR$ (or the location where file is located) to location $INSTALLER_TEMP_DIR$.
2. Add this file in Install tab under magic folder name "DO NOT INSTALL".
3. You can now run this file at pre-install tab from location $INSTALLER_TEMP_DIR$$/$
0 Kudos
jungek
Level 2

trehananirudh wrote:
May be this is too late but this can be done in following steps -

1. Add action plugin: extract to file at pre-installation and extract required file from location $IA_PROJECT_DIR$ (or the location where file is located) to location $INSTALLER_TEMP_DIR$.
2. Add this file in Install tab under magic folder name "DO NOT INSTALL".
3. You can now run this file at pre-install tab from location $INSTALLER_TEMP_DIR$$/$


I am trying to run myfile.exe during preinstall to verify the product key, and I get runtime exception from ExtractToFile.install() method. I put myfile.exe in $DO_NOT_INSTALL$ and added ExtractToFile plugin with the following options:

Source: $DOLLAR$IA_PROJECT_DIR$DOLLAR$$/$myfile.exe
Destination: $INSTALLER_TEMP_DIR$$/$myfile.exe

I tried the source path with the dollar sign, without the dollar sign, back slash, forward slash, all different variables I can think of but the plugin throws runtime exception EVERY TIME. Has anyone successfully used ExtractToFile plugin to extract an exe during preinstall? Is this a working plugin?
0 Kudos
gmathew
Level 2

I had the same issue too. I discovered that my jars that I added to the DO_NOT_INSTALL folder was placed not in $DOLLAR$IA_PROJECT_DIR$DOLLAR$.

So when the install initializes, it dumps this file call Execute.zip. This contains your plugins and the files you placed in the DO_NOT_INSTALL folder. My files were located in C_/folder1/subfolder2/my.jar. When you set the ExtractToFile_Source, the file path starts at the root of the Execute.zip.
0 Kudos