Share via

Power shell write-progress

Jcam23 0 Reputation points
2026-03-12T14:35:10.31+00:00

Good morning,

                  Using Software center on a closed environment to install various versions of Matlab.  MathWorks removed the "automated" feature mode from their installer input file starting with R2020. When a user runs the installation via Software Center it will indicate failure even though the matlab installer is running in the background, but the user does not know this.

trying to create a power shell write-progress script to track installation(I am not a scripting expert), so the user can see that it is running. but i can't get it to work. has anyone come across this issue or have a better solution?

Thank You!

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Harry Phan 15,915 Reputation points Independent Advisor
    2026-03-12T15:18:15.6+00:00

    Hi Jcam,

    When deploying through Microsoft Configuration Manager Software Center, the system only checks whether the installer process has finished, not what it displays on screen. The newer MATLAB installer launches another process in the background and exits early, so Software Center thinks the installation failed even though it is still running. The practical fix is to run the installer through a small PowerShell wrapper that forces the system to wait until the real installation process finishes using Start-Process -Wait. This way Software Center will keep showing the installation as “in progress” until MATLAB actually completes. Progress bars like Write-Progress usually will not appear in Software Center, so the best approach is simply making the deployment wait correctly.

    If you find it's helpful, pleave give it a thump up or accept the answer, very much appreciate it :)

    Harry.

    You found this answer helpful.

  2. Q&A Assist
    2026-03-12T14:35:31.34+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    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:

    1. 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.
    2. 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.
    3. 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
    
    1. 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).
    2. 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:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.