Use Write-Progress in a wrapper script that launches the MATLAB installer and periodically updates the progress bar while the installer runs. Write-Progress only shows something while the PowerShell script itself is running, so the wrapper must stay active until setup finishes.
Example pattern:
$ProgressPreference = 'Continue' # Ensure progress is shown
# Start MATLAB installer in background
$process = Start-Process -FilePath "C:\Path\to\matlab_installer.exe" `
-ArgumentList "<your arguments>" `
-PassThru -WindowStyle Hidden
$activity = "Installing MATLAB"
$status = "MATLAB setup is running. Do not close this window."
while (-not $process.HasExited) {
# If no real percentage is available, use an indeterminate style
Write-Progress -Activity $activity -Status $status -PercentComplete 0
Start-Sleep -Seconds 5
}
# Final update when done
Write-Progress -Activity $activity -Status "Installation complete." -PercentComplete 100
Key points:
-
Write-Progress basics
-
-Activity is the main text line (what is happening).
-
-Status is the secondary text line (more detail).
-
-PercentComplete is an integer 0–100.
- If the progress bar does not appear, ensure
$ProgressPreference is not set to SilentlyContinue.
- Handling unknown duration
- If the MATLAB installer does not expose progress, keep
-PercentComplete 0 (indeterminate) and just update -Status periodically.
- Optionally, add a spinner or elapsed time in
-Status to show that work is ongoing.
- Returning success to Software Center
- The wrapper script should exit with the installer’s exit code so Software Center reports success/failure correctly:
$process.WaitForExit()
$exitCode = $process.ExitCode
Write-Progress -Activity $activity -Status "Installation complete." -PercentComplete 100
exit $exitCode
- Multiple steps (optional)
- If there are multiple phases (e.g., pre-checks, install, post-config), use different
-Activity or -Status messages and adjust -PercentComplete to reflect rough stages (e.g., 0–20–80–100).
- PowerShell 7+ progress style (optional)
- In PowerShell 7.2+, progress rendering can be tuned with
$PSStyle.Progress:
$PSStyle.Progress.View = 'Classic' # or 'Minimal'
$PSStyle.Progress.MaxWidth = 120
This wrapper can be the program that Software Center runs. The user then sees a PowerShell progress bar while MATLAB installs in the background, and Software Center gets the correct final result.
References: