This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Running exe during preinstall
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
‎Mar 08, 2013
05:21 PM
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
> 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
(6) Replies
‎Mar 11, 2013
02:02 AM
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
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$\
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
‎Mar 11, 2013
09:33 AM
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
‎Jul 26, 2013
03:32 PM
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;
}
}
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;
}
}
‎Aug 22, 2013
07:22 AM
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$$/$
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$$/$
‎Jun 12, 2014
12:34 PM
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?
‎Jun 02, 2015
01:29 PM
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.
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.