- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- execute a batch script as a pre-install task
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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:
- go with custom action of immediate sequence
- Custom action of type of executable file(Or Exe stored in binary table) with [SystemFolder]\cmd.exe /c <full_path_of_batch_file>
- Sequence it well-before installation as you mentioned pre-installation task
- Or if you want to go with script based you can use installscript function LaunchApp,please refer below KB article:
- https://community.flexera.com/t5/InstallShield-Knowledge-Base/Running-a-Batch-File-from-Your-Setup/ta-p/4449
Let me know if that helps,
Thanks,
Jenifer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
how to get the INSTALLDIR location inside a batchscript ?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Nice post and thanks for sharing this and get more details about online information. |
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)