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

HOW TO: Launch a bat file from INSTALLDIR/SUPPORTDIR using Custom Action

HOW TO: Launch a bat file from INSTALLDIR/SUPPORTDIR using Custom Action

Introduction

This article will discuss one possible method of Launching a batch file using a custom action.

Instructions

To Launch a batch file using Custom Action we should follow below steps
 

Method:1 Launching from INSTALLDIR

 
  1. Create a Project and Add your batch file in Files and Folder[INSTALLDIR]
  2. Create a New EXE Custom Action [ Type: New EXE , Path referencing a directory]
  3. Set the Working Directory: SystemFolder
  4. File Name and Command Line: cmd.exe /c  "[INSTALLDIR]test.bat"
  5. Return Processing: Synchronous (Check Exit code)
  6. In-Script Execution: Immediate Execution
  7. Set the Install Exec Sequence "After InstallFinalize"
  8. Add a condition if  you want to run this action only on installation EX: Not Installed
  9. CA settings.JPG

Method:2 Launching from SUPPORTDIR

  1. Create a Project and Add your batch file to Behavior And Logic Supportfiles --> Language Independent 
  2. Adding files to supportfiles.JPG
  3. Create a New EXE Custom Action [ Type: New EXE , Path referencing a directory]
  4. Set the Working Directory: SystemFolder
  5. File Name and Command Line: "[SystemFolder]cmd.exe" /c "[SUPPORTDIR]\test.bat"
  6. Return Processing: Synchronous (Check Exit code)
  7. In-Script Execution: Deferred Execution in System Context
  8. Set the Install Exec Sequence "After InstallFinalize" or "After InstallFiles"
  9. Add a condition if  you want to run this action only on installation EX: Not Installed
  10. CA settings_deffered Exec.JPG

 

More Information

Click here  for details on how to launch batch file using installscript .

Additional Information:

"[SystemFolder]cmd.exe /c  "[INSTALLDIR]test.bat"

This command calls cmd.exe (the executable for the Windows command prompt) from the location stored in the SystemFolder MSI property and passes cmd.exe the path to the batch file. Cmd.exe accepts various parameters. For example, to have the command prompt window close after launching the batch file, use the /c parameter, as in the example above. To have the command prompt window remain open after launching the batch file, use the /k parameter instead.

For more information regarding the parameters accepted by cmd.exe, click here cmd exe  

Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Oct 27, 2023 04:21 AM
Updated by:
Contributors