02-22-2022 04:51 AM
I try to create an automatic installation script that will install LabVIEW for me. I use PowerShell and NIPM CLI.
I tried to use:
$Process = Start-Process $ManagerPath -ArgumentList $InstallArguments -Wait -NoNewWindow -PassThru
if($Process.ExitCode -eq 0){}
This is a nice and popular method for calling executables from PowerShell. But the problem is that the LabVIEW installer always hangs at error -125071 which indicates "installation success, reboot required". So the process never ends (I use -Wait
for obvious reason). I tried nipkg.exe (which does not have a "prevent reboot" flag but does not reboot by itself) and NIPackageManager.exe where I can specify the "prevent reboot" flag. I tried multiple flags but it always hangs at the and.
If I tried the same method for TestSTand installer it works as expected even though the status is the same (-125071). So, the process ends and the script can proceed.
What is wrong with the LabVIEW installer? Or am I mistaken somewhere?
Notes to recreate my solution:
LabVIEW
$Feed = "https://download.ni.com/support/nipkg/products/ni-l/ni-labview-2021-x86/21.1/released"
$Package = 'ni-labview-2021-core-x86-en="21.1.0.49478-0+f326"'
TestStand
$Feed = "https://download.ni.com/support/nipkg/products/ni-t/ni-teststand-2021-x86/21.0/released"
$Package = 'ni-teststand-2021-x86="21.0.0.49155-0+f3"'
For nipkg.exe
$ManagerPath = "C:\Program Files\National Instruments\NI Package Manager\nipkg.exe"
$InstallArguments = "install $Package --accept-eulas --assume-yes --include-recommended"
Start-Process $ManagerPath -ArgumentList "feed-add $Feed" -Wait -NoNewWindow -PassThru
Start-Process $ManagerPath -ArgumentList "update" -Wait -NoNewWindow -PassThru
Start-Process $ManagerPath -ArgumentList $InstallArguments -Wait -NoNewWindow -PassThru
For NIPackageManager.exe
$ManagerPath = "C:\Program Files\National Instruments\NI Package Manager\NIPackageManager.exe"
$InstallArguments = "install $Package --temp-feeds=$Feed --passive --force-essential --accept-eulas --prevent-reboot"
I don't know why but only --temp-feeds
works for me. I thought it would be --feeds
. I tried --passive
and --quiet
but with --passive
I have some feedback at least.
Start-Process $ManagerPath -ArgumentList $InstallArguments -NoNewWindow -PassThru
02-22-2022 09:31 AM
I think your best bet would be to use NI Package Builder to build a Package Installer. You will need to have the desired packages already installed, but then you can automatically run the Package Installer from the command line. KB about this I have used this to deploy installation and updates.
02-22-2022 01:17 PM
@CL_eisenwr wrote:
I think your best bet would be to use NI Package Builder to build a Package Installer. You will need to have the desired packages already installed, but then you can automatically run the Package Installer from the command line. KB about this I have used this to deploy installation and updates.
That is definitely NOT the best option. I can install LV using CMD but the problem I describe is more about using PowerShell Start-Process and inconsistency in NI installers.
02-23-2022 09:32 AM - edited 02-23-2022 09:34 AM
For what it's worth, the following appears to be the current content (or at least, a subset) of my Dockerfile to install LabVIEW:
# Change the default shell
SHELL ["powershell"]
# Allow execution of powershell scripts
# Add the appropriate feeds for 2021, 32-bit.
COPY AddFeeds_2021-32bit.ps1 AddFeeds.ps1
RUN Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine ; `
.\AddFeeds.ps1 ; `
Remove-Item AddFeeds.ps1 ;
RUN nipkg.exe install --accept-eulas -y --include-recommended `
ni-labview-2021-core-x86-en `
ni-certificates `
ni-labview-2021-vi-analyzer-toolkit-x86 `
ni-labview-2021-aspt-toolkit-x86 `
ni-sv-toolkit-2021-x86; `
$LASTEXITCODE
I remember the error you describe, but I guess I just echo it to the console - since the echoing succeeds, the eventual error code is 0 (because printing worked, regardless of the code being printed).
I'm surprised to see the "--include-recommended" flag here, but I suppose I was feeling imprecise when I wrote this (I don't remember using that for my 2019 version of this file).
06-17-2025 08:52 AM
I was running into something similar where I needed to automate the Install.exe for some offline packages and was a part of a bigger PowerShell. It kept getting hung with Start-Process and I needed the exit code. Using cmd.exe /c with the full install string plus echoing the exit code in the same line works reliably for me even though it's pretty ugly.
$PackagesPath = "C:\NiPackages\Install.exe"
$bundleInstallArgs = @(
"--passive",
"--accept-eulas",
"--prevent-reboot"
)
$bundleArgsString = $bundleInstallArgs -join ' '
$quotedInstallerPath = '"' + $PackagesPath + '"'
# Example: "C:\NiPackages\Install.exe" --passive --accept-eulas --prevent-reboot & call echo EXITCODE:^%errorlevel^%
$cmdLine = "$quotedInstallerPath $bundleArgsString & call echo EXITCODE:^%errorlevel^%"
$cmdOutput = cmd.exe /c $cmdLine
# Debug output
Write-Host "`nFull CMD output:"
$cmdOutput | ForEach-Object { Write-Host $_ }
# Parse exit code from output
$exitCodeLine = $cmdOutput | Where-Object { $_ -match '^EXITCODE:' }
if ($exitCodeLine) {
$exitCode = [int]($exitCodeLine -replace '^EXITCODE:')
Write-Host "`nCaptured Exit Code: $exitCode"
}
else {
Write-Host "`nCould not parse EXITCODE from output."
exit 9999
}
# Handle known exit codes
switch ($exitCode) {
0 { Write-Host "Installation successful. No reboot required."; exit 0 }
-125071 { Write-Host "Installation successful, reboot required."; exit 3010 }
-126300 { Write-Host "Only NI Package Manager installed, reboot and re-run required."; exit 1618 }
default { Write-Host "Installation failed or unknown code: $exitCode"; exit $exitCode }
}
06-24-2025 07:42 AM - edited 06-24-2025 08:25 AM
Have you tried using --uri="<URI>" ?
for example - .\NIPackageManager.exe --uri="nipkg://store/1/install-item/ni-teststand-2021_21.1"
07-01-2025 03:17 PM - edited 07-01-2025 03:19 PM
I have dealt with this problem many times. My primary problem was that NIPKG installation started but shell did not wait till end. The code below made a trick. When it comes to online install, all you need to do it is download. Currently working on some opensource scripts to install LabVIEW and NIPKG installation is key there.
function Install-NipkgManager {
param (
[string]$InstallerPath
)
$timeout = 300000 # 5 minutes
# Set up the process start info
$process = New-Object System.Diagnostics.Process
$process.StartInfo.FileName = $InstallerPath
$process.StartInfo.Arguments = "--quiet --accept-eulas --prevent-reboot"
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.CreateNoWindow = $false
# Start the process
$process.Start()
# Wait for it to exit
$process.WaitForExit($timeout)
# Capture the exit code
$exitCode = $process.ExitCode
# Optionally capture output or error text
$output = $process.StandardOutput.ReadToEnd()
$errorOutput = $process.StandardError.ReadToEnd()
# Display results
Write-Host "Exit Code: $exitCode"
Write-Host "Output: $output"
Write-Host "Error Output: $errorOutput"
}