cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vlexdev
Level 4

execute a batch script as a pre-install task

i tried to execute a batch script as a pre-install task, but during installation it always throws an error.can anyone help me how to execute a batch script in installshield as part of pre-installation task?

Labels (1)
0 Kudos
(6) Replies
Jenifer
Flexera Alumni

Hi @vlexdev ,

How are you trying to execute batch script as a pre-installation task?

What is the error you are facing?

i would recommend you to:

Let me know if that helps,

 

Thanks,

Jenifer

0 Kudos

Hi @vlexdev ,

 

This helpnet link can help you writing installscript functions by following steps mentioned:

https://helpnet.flexerasoftware.com/installshield22helplib/helplibrary/IHelpIScriptOverview.htm

You have to declare datatype of these three variables,the sample function would be like this here:

function MyFunction(hMSI)
// To Do: Declare local variables.
STRING szProgram,szCmdline;
begin
szProgram = "C:\\Users\\Admin\\Desktop\\TestData\\ExecuteBat.bat";
szCmdline = SystemFolder+"\\cmd.exe /c";
LaunchApp (szProgram,szCmdline);
// To Do: Write script that will be executed when MyFunction is called.

end;

  • Create InstallScript custom action and add myfunction as function name
  • Let In-Script execution be Immediate execution
  • add InstallationExecution sequence as say "After CostInitialize"
  • Build the project and execute,you will be able to see batch script execution

Thanks,

Jenifer

0 Kudos

The batch script gets executed only when i hardcode the path inide the batch script. for example: to create a directory inside my taget installation folder, i have to give the whole path of the folder inside the script. Instead of hardcoding how can i get the variable that represents the user installation folder.

how to get the INSTALLDIR location inside a batchscript ?
0 Kudos

Hi @vlexdev ,

 

You have to use INSTALLDIR variable inside code,sample code would be:

szProgram =INSTALLDIR^"\\ExecuteBat.bat";
szCmdline = SystemFolder+"\\cmd.exe /c";
LaunchApp (szProgram,szCmdline);

 

Thanks,

Jenifer

0 Kudos

For e.g: The content in my batch file is :-
md "INSTALLDIR^\Software_installation\Logs"
// i want to create a folder "Software_installation" inside my installation directory.
How to useinstalldir varibale like this inside the batch file?

In the installscript file, the code is:-
function MyFunction(hMSI)
// To Do: Declare local variables.
STRING szProgram,szCmdline;
begin
szProgram = "C:\\Users\\rr9\\Desktop\\Bat files\\creating a directory.bat";
szCmdline = SystemFolder+"\\cmd.exe/c";
LaunchApp (szProgram,szCmdline);
end

0 Kudos

Nice post and thanks for sharing this and get more details about online information.

http://nbiclearance.website/

0 Kudos