Configuring NI Package Manager to Skip Custom Actions During Updates

Updated Jan 29, 2025

Reported In

Software

  • NI Package Builder
  • Package Manager

Issue Details

I use NI Package Builder and NI Package Manager to manage software. I use the custom execute feature to include a script that runs after the installation. Everything goes fine when my package is first installed. However, it struggles when the same package is installed as an update. Can I configure it to skip custom executes during updates? 

Solution

Currently, you can’t conditionally call a custom execute within a package during updates. To manage this, add logic to your custom execute code. Set a flag during the initial installation or update, such as a specific file. During subsequent updates, the custom execute can check for this flag to decide on actions. Ensure the flag is removed during uninstallation.

The section below describes a simple example script you could use to differentiate installs from updates in custom executions.

 

Using a file as a flag for updates

During Install or Update

In your custom execute batch script, create a file named install_flag.txt in a specific directory if it doesn’t already exist.

@echo off
if not exist C:\path\to\install_flag.txt (
    REM You might want to add some custom text to the install_flag.txt file to indicate installation status or details.
    echo Installation complete > C:\path\to\install_flag.txt
    echo Performing custom action
    REM Add your custom action code here
) else (
    echo Skipping custom action during update
)

During Uninstall 

Remove the install_flag.txt file.

@echo off
if exist C:\path\to\install_flag.txt (
    del C:\path\to\install_flag.txt
)

By using this method, you can control custom executes during updates, ensuring they only run when necessary.