Running a Batch File From a Package Created With NI Package Builder

Updated Apr 9, 2024



  • NI Package Builder

In a NI Package Manager-based installer, I need to run batch commands. How can I implement that in my packages?

In NI Package Builder, you can add batch files to your target and use Custom executes to run those files. Follow these steps:

(1) Create your batch file yourbatchfile.bat (or similar)

(2) In NI Package Builder, add your batch file to your Inputs

(3) Add your batch file to your package via Drag-and-Drop. This way it will be installed to the target with the package.

(4) Next, advise your package to run Custom executes. In NI Package Builder go to the Packages pane. There choose your package. In the Properties of your package, search for Custom executes (this is the last entry) and press 

(4.1) In the Manage Custom Executes Popup, make sure, you choose Post All Install.

(4.2) Create a new Execute by pressing New. Now choose the path to your batchfile – it will be something similar to:
Root: [Program Files (64-bit)]
Relative Executable Path: Your Software\Support\yourbatchfile.bat

(4.3) If appropriate, set the checkboxes for Wait to completeIgnore errors or Show console window. Then press OK.

Now you are done. Create your package and your installer. The installer will also run yourbatchfile.bat.

Additional Information

Custom executes can run single lines of batch commands without installing a .bat file. Attention: Custom executes do create temporary bat files which are saved to the local %TEMP% folder and executed from there. So you cannot implement admin access with custom executes. If you need admin rights, use .bat files instead (and, for example, put them into the support folder of your software). More on Custom Executes can be found in the NI Package Builder Help: Custom Executes article.

As your NI Package Manager installs packages as admin, your Batch files will have admin rights, too.