Implementing Live Progress Bar, Timer, and Completion Notification in Task Kill Action Script

Hi BigFix Community,

I am currently working on refining our task kill and application deployment workflows. While we can already notify users to save their work before termination using native BigFix features, I am looking to implement additional features.

Specifically, is it possible to integrate a live, percentage-based progress bar within the action script to track the status of the downloading and installation steps in real time, accompanied by a timer showing the elapsed time?

Additionally, I want to ensure the user receives a notification on their screen once the 100% completion is successfully achieved. Any guidance or script examples for achieving this would be highly appreciated.

@vk.khurava @JasonWalker looking for your expertise. If this could be possible or not. If possible what will be the best possible way to implement this.

Hi @Rishabh there are a few reasons why BigFix cannot display a true real-time progress bar:

  1. Prefetch downloads complete before the action script starts, so download progress cannot be tracked through the action itself.

  2. SYSTEM context: The BigFix Client runs as SYSTEM, so anything launched directly by the action is not visible to the logged-on user.

  3. Messages tab: The native "Display message while running" option supports only static text, without a dynamic percentage or timer.

Possible alternatives:

  1. Simple: Enable "Display message while running" under the Messages tab in the Take Action dialog.

  2. Better: Have the action script write progress updates (e.g., 30%, 90%, 100%) to a text file after each step. A separate PowerShell window running in the user's session can read this file and display a progress bar, elapsed timer, and completion notification.

Last but not least, this is indeed a good feature suggestion! I'd recommend raising an RFE (Request for Enhancement) with HCL. If enough customers support and vote for it, it may gain priority for implementation in a future release.

FYI – Update: I tested a small Action Script to validate the second option I suggested earlier. You can use the script below to test it on your end.

folder create "C:\ProgramData\BFProgress"

// ---- 5% : preparing ----
delete "C:\ProgramData\BFProgress\status.txt"
delete __createfile
createfile until END_OF_FILE
5|Preparing...
END_OF_FILE
move __createfile "C:\ProgramData\BFProgress\status.txt"

// ---- Launch UI only if a user is logged on (non-blocking) ----
if {exists logged on users}
override run
runas=currentuser
hidden=true
run powershell.exe -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\ProgramData\BFProgress\Show-Progress.ps1"
endif

waithidden powershell.exe -NoProfile -Command "Start-Sleep -Seconds 5"

// ---- 30% : kill application ----
waithidden taskkill.exe /F /IM notepad.exe
delete "C:\ProgramData\BFProgress\status.txt"
delete __createfile
createfile until END_OF_FILE
30|Application closed. Installing...
END_OF_FILE
move __createfile "C:\ProgramData\BFProgress\status.txt"

// ---- 90% : install (simulated - replace with real installer) ----
waithidden powershell.exe -NoProfile -Command "Start-Sleep -Seconds 10"
delete "C:\ProgramData\BFProgress\status.txt"
delete __createfile
createfile until END_OF_FILE
90|Finalizing...
END_OF_FILE
move __createfile "C:\ProgramData\BFProgress\status.txt"

waithidden powershell.exe -NoProfile -Command "Start-Sleep -Seconds 5"

// ---- 100% : completed ----
delete "C:\ProgramData\BFProgress\status.txt"
delete __createfile
createfile until END_OF_FILE
100|Installation completed successfully
END_OF_FILE
move __createfile "C:\ProgramData\BFProgress\status.txt"

// ---- cleanup ----
waithidden powershell.exe -NoProfile -Command "Start-Sleep -Seconds 5"
delete "C:\ProgramData\BFProgress\status.txt"

Thanks @vk.khurava for testing this approach and sharing the example.

I have a few follow-up questions because I'm trying to understand how to implement this correctly in an actual BigFix application deployment.

I tested the Action Script you provided directly through BigFix on a couple of test devices. The action executed, but I did not receive the PowerShell progress/message window in the logged-on user's session.

Could you please provide a little more detail on the following?

  1. Can Show-Progress.ps1 be dynamically created by the BigFix Action Script itself before it is launched, rather than deploying the .ps1 file separately?

  2. For testing purposes, what should the contents of Show-Progress.ps1 be? In the example Action Script, I see: -File "C:\ProgramData\BFProgress\Show-Progress.ps1"

    but I'm not sure how this PowerShell script should initially be created or deployed.

  3. What is the recommended way to launch the PowerShell UI in the currently logged-on user's interactive session, considering that the BigFix Client and Action Script are running as SYSTEM?

  4. Is there a simple test Action Script that I can run first to confirm that BigFix can successfully display a PowerShell message/progress window to the logged-on user before integrating it into an actual application deployment?

  5. Once that is working, how would you recommend integrating it into an existing application installation? For example:

    Preparing → Closing Application → Installing → Finalizing → Completed / Failed → Restart Required

  6. How should installer failures and timeouts be handled so that the progress UI can display Failed, Completed, or Restart Required, rather than relying only on predefined percentage values?

  7. If a restart is required after installation, can the same UI provide Restart Now and Postpone options and return the user's selection back to the BigFix action?

Ultimately, I'm trying to build a reusable solution where the BigFix installation continues to run as SYSTEM, while the logged-on user receives a separate interactive PowerShell UI showing the deployment status.

If possible, could you share a complete working test example containing both the BigFix Action Script and Show-Progress.ps1? That would help me validate the basic functionality first and then integrate it into my existing application installation Fixlets.

Ah, that's because I forgot to include the PowerShell script that actually generates the progress bar. I used Copilot to help create it and have shared the complete Show-Progress.ps1 script below, which you can modify as needed.

Regarding your questions:

# =====================================================================
# Show-Progress.ps1  v2  -  BigFix user-session status UI (display-only)
# Launched by BigFix: override run / runas=currentuser
# Reads C:\ProgramData\BFProgress\status.txt  (one line):
#     <0-99>|<message>      progress step
#     100|<message>          completed  (green)
#     REBOOT|<message>       completed, restart required (amber)
#     FAIL|<message>         failed (red)
# Windows PowerShell 5.1, no external modules. ASCII-only source.
# =====================================================================
Add-Type -AssemblyName System.Windows.Forms, System.Drawing
[Windows.Forms.Application]::EnableVisualStyles()
$StatusFile    = 'C:\ProgramData\BFProgress\status.txt'
$WindowTitle   = 'IT Deployment'
$SafetyMins    = 120
$CloseAfterSec = 20
# one window per user session
$script:mtx = New-Object Threading.Mutex($false, 'Local\BFProgressUI')
if (-not $script:mtx.WaitOne(0)) { exit }
if (-not ('BFNative' -as [type])) {
Add-Type @"
using System; using System.Runtime.InteropServices;
public static class BFNative {
  [DllImport("dwmapi.dll")] public static extern int DwmSetWindowAttribute(IntPtr h, int a, ref int v, int s);
  [DllImport("user32.dll")] public static extern bool ReleaseCapture();
  [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr h, int m, IntPtr w, IntPtr l);
}
"@
}
# ---------- palette ----------
$cBgTop    = [Drawing.Color]::FromArgb(36, 38, 48)
$cBgBottom = [Drawing.Color]::FromArgb(24, 25, 32)
$cBorder   = [Drawing.Color]::FromArgb(58, 61, 74)
$cTrack    = [Drawing.Color]::FromArgb(46, 48, 60)
$cText     = [Drawing.Color]::FromArgb(245, 246, 250)
$cSub      = [Drawing.Color]::FromArgb(178, 184, 198)
$cMuted    = [Drawing.Color]::FromArgb(122, 128, 145)
$script:c1 = [Drawing.Color]::FromArgb(56, 140, 255)    # blue   (running)
$script:c2 = [Drawing.Color]::FromArgb(150, 92, 255)    # violet
$Final = @{
  DONE   = @{ C1=[Drawing.Color]::FromArgb(34,197,94);  C2=[Drawing.Color]::FromArgb(16,185,129); Glyph=[char]0x2713; Word='Completed';        Icon='Info';    Hint='' }
  REBOOT = @{ C1=[Drawing.Color]::FromArgb(245,158,11); C2=[Drawing.Color]::FromArgb(234,88,12);  Glyph=[char]0x21BB; Word='Restart required'; Icon='Warning'; Hint='Save your work' }
  FAIL   = @{ C1=[Drawing.Color]::FromArgb(239,68,68);  C2=[Drawing.Color]::FromArgb(190,24,93);  Glyph=[char]0x2715; Word='Failed';           Icon='Error';   Hint='Contact IT Service Desk' }
}
# ---------- state ----------
$script:target = 0.0; $script:cur = 0.0; $script:shim = -120
$script:pollMs = 0;   $script:done = $false; $script:doneAt = $null; $script:finalHint = ''
$sw = [Diagnostics.Stopwatch]::StartNew()
function New-RoundPath([float]$x, [float]$y, [float]$w, [float]$h, [float]$r) {
    $p = New-Object Drawing.Drawing2D.GraphicsPath
    $d = [Math]::Min($r * 2, [Math]::Min($w, $h))
    if ($d -lt 1) { $p.AddRectangle((New-Object Drawing.RectangleF $x, $y, $w, $h)); return ,$p }
    $p.AddArc($x, $y, $d, $d, 180, 90)
    $p.AddArc($x + $w - $d, $y, $d, $d, 270, 90)
    $p.AddArc($x + $w - $d, $y + $h - $d, $d, $d, 0, 90)
    $p.AddArc($x, $y + $h - $d, $d, $d, 90, 90)
    $p.CloseFigure()
    return ,$p
}
function Set-DoubleBuffer($ctl) {
    [Windows.Forms.Control].GetProperty('DoubleBuffered', [Reflection.BindingFlags]'NonPublic,Instance').SetValue($ctl, $true, $null)
}
# ---------- form (bottom-centre, clear of Windows notifications) ----------
$form = New-Object Windows.Forms.Form
$form.FormBorderStyle = 'None'; $form.ShowInTaskbar = $false; $form.TopMost = $true
$form.Size = New-Object Drawing.Size 460, 196
$form.BackColor = $cBgBottom; $form.Opacity = 0
$wa = [Windows.Forms.Screen]::PrimaryScreen.WorkingArea
$form.StartPosition = 'Manual'
$form.Location = New-Object Drawing.Point ([int]($wa.Left + ($wa.Width - $form.Width) / 2)), ($wa.Bottom - $form.Height - 40)
Set-DoubleBuffer $form
$form.Add_Paint({ param($s, $e)
    $g = $e.Graphics; $g.SmoothingMode = 'AntiAlias'
    $rect = New-Object Drawing.Rectangle 0, 0, $s.Width, $s.Height
    $br = New-Object Drawing.Drawing2D.LinearGradientBrush $rect, $cBgTop, $cBgBottom, 90
    $g.FillRectangle($br, $rect); $br.Dispose()
    $pen = New-Object Drawing.Pen $cBorder, 1
    $g.DrawRectangle($pen, 0, 0, $s.Width - 1, $s.Height - 1); $pen.Dispose()
    $strip = New-Object Drawing.Rectangle 0, 0, $s.Width, 3
    $sb = New-Object Drawing.Drawing2D.LinearGradientBrush $strip, $script:c1, $script:c2, 0
    $g.FillRectangle($sb, $strip); $sb.Dispose()
})
$dragHandler = { [BFNative]::ReleaseCapture() | Out-Null; [BFNative]::SendMessage($form.Handle, 0xA1, [IntPtr]2, [IntPtr]::Zero) | Out-Null }
$form.Add_MouseDown($dragHandler)
function New-Lbl($text, $x, $y, $w, $h, $font, $color, $align = 'MiddleLeft') {
    $l = New-Object Windows.Forms.Label
    $l.Text = $text; $l.Location = New-Object Drawing.Point $x, $y; $l.Size = New-Object Drawing.Size $w, $h
    $l.Font = $font; $l.ForeColor = $color; $l.BackColor = [Drawing.Color]::Transparent; $l.TextAlign = $align
    $l.Add_MouseDown($dragHandler)
    $form.Controls.Add($l); return $l
}
$lblTitle = New-Lbl $WindowTitle 22 18 380 24 (New-Object Drawing.Font 'Segoe UI Semibold', 12) $cText
$lblClose = New-Lbl ([string][char]0x2715) 420 12 28 28 (New-Object Drawing.Font 'Segoe UI', 10) $cMuted 'MiddleCenter'
$lblClose.Cursor = 'Hand'
$lblClose.Add_MouseEnter({ $lblClose.ForeColor = $cText }); $lblClose.Add_MouseLeave({ $lblClose.ForeColor = $cMuted })
$lblClose.Add_Click({ $form.Close() })   # hides window only - BigFix action keeps running
$lblStep = New-Lbl 'Starting...' 22 52 300 22 (New-Object Drawing.Font 'Segoe UI', 10) $cSub
$lblPct  = New-Lbl '0%' 318 44 120 36 (New-Object Drawing.Font 'Segoe UI Semibold', 20) $cText 'MiddleRight'
$lblTime = New-Lbl 'Elapsed  00:00' 22 146 150 22 (New-Object Drawing.Font 'Segoe UI', 9) $cMuted
$lblHint = New-Lbl 'Please keep your device on' 172 146 266 22 (New-Object Drawing.Font 'Segoe UI', 9) $cMuted 'MiddleRight'
# ---------- glossy bar ----------
$bar = New-Object Windows.Forms.Panel
$bar.Location = New-Object Drawing.Point 22, 98; $bar.Size = New-Object Drawing.Size 416, 22
$bar.BackColor = $cBgBottom
Set-DoubleBuffer $bar
$form.Controls.Add($bar)
$bar.Add_Paint({ param($s, $e)
    $g = $e.Graphics; $g.SmoothingMode = 'AntiAlias'; $g.PixelOffsetMode = 'HighQuality'
    $W = [float]($s.Width - 1); $H = [float]($s.Height - 1); $R = $H / 2
    $g.Clear($cBgBottom)
    $track = New-RoundPath 0 0 $W $H $R
    $tb = New-Object Drawing.SolidBrush $cTrack; $g.FillPath($tb, $track); $tb.Dispose()
    $ip = New-Object Drawing.Pen ([Drawing.Color]::FromArgb(70, 0, 0, 0)), 1
    $g.DrawPath($ip, $track); $ip.Dispose()
    $fw = [float]($W * $script:cur / 100.0)
    if ($fw -ge 2) {
        $fw = [Math]::Max($fw, $H)
        $fill = New-RoundPath 0 0 $fw $H $R
        $fr = New-Object Drawing.RectangleF 0, 0, ([Math]::Max($fw, 2)), ($H + 1)
        $gb = New-Object Drawing.Drawing2D.LinearGradientBrush $fr, $script:c1, $script:c2, 0
        $g.FillPath($gb, $fill); $gb.Dispose()
        $g.SetClip($fill)
        $gr = New-Object Drawing.RectangleF 0, 0, $fw, ($H / 2 + 1)
        $gl = New-Object Drawing.Drawing2D.LinearGradientBrush $gr, ([Drawing.Color]::FromArgb(150, 255, 255, 255)), ([Drawing.Color]::FromArgb(25, 255, 255, 255)), 90
        $g.FillRectangle($gl, $gr); $gl.Dispose()
        if (-not $script:done) {
            $sr = New-Object Drawing.RectangleF ([float]$script:shim), 0, 110, ($H + 1)
            $sb = New-Object Drawing.Drawing2D.LinearGradientBrush $sr, ([Drawing.Color]::Transparent), ([Drawing.Color]::Transparent), 0
            $cb = New-Object Drawing.Drawing2D.ColorBlend 3
            $cb.Colors    = @([Drawing.Color]::FromArgb(0, 255, 255, 255), [Drawing.Color]::FromArgb(110, 255, 255, 255), [Drawing.Color]::FromArgb(0, 255, 255, 255))
            $cb.Positions = @([single]0, [single]0.5, [single]1)
            $sb.InterpolationColors = $cb
            $g.FillRectangle($sb, $sr); $sb.Dispose()
        }
        $g.ResetClip()
        $ep = New-Object Drawing.Pen ([Drawing.Color]::FromArgb(90, 255, 255, 255)), 1
        $g.DrawPath($ep, $fill); $ep.Dispose(); $fill.Dispose()
    }
    $track.Dispose()
})
# ---------- notification ----------
$notify = New-Object Windows.Forms.NotifyIcon
$notify.Icon = [Drawing.SystemIcons]::Information
$notify.Text = $WindowTitle
function Set-Final([string]$state, [string]$msg) {
    $f = $Final[$state]
    $script:done = $true; $script:doneAt = $sw.Elapsed
    $script:c1 = $f.C1; $script:c2 = $f.C2
    if ($state -ne 'FAIL') { $script:target = 100 }
    $lblTitle.Text = $WindowTitle + '  ' + $f.Glyph + ' ' + $f.Word
    $lblStep.Text  = $msg
    $lblTime.Text  = 'Total time  ' + $sw.Elapsed.ToString('mm\:ss')
    $script:finalHint = $f.Hint
    $form.Invalidate()
    $notify.Visible = $true
    $notify.ShowBalloonTip(10000, ($WindowTitle + ' - ' + $f.Word), ($msg + "`nTotal time: " + $sw.Elapsed.ToString('mm\:ss')), $f.Icon)
}
function Read-Status {
    if (-not (Test-Path $StatusFile)) { return }
    $line = Get-Content $StatusFile -ErrorAction SilentlyContinue | Select-Object -First 1
    if (-not $line) { return }
    $p   = "$line" -split '\|', 2
    $key = $p[0].Trim().ToUpper()
    $msg = ''; if ($p.Count -eq 2) { $msg = $p[1].Trim() }
    $pct = 0
    if ([int]::TryParse($key, [ref]$pct)) {
        $pct = [Math]::Max(0, [Math]::Min(100, $pct))
        $script:target = [double]$pct
        if ($pct -ge 100) { Set-Final 'DONE' $msg } else { $lblStep.Text = $msg }
    }
    elseif ($key -eq 'REBOOT') { Set-Final 'REBOOT' $msg }
    elseif ($key -eq 'FAIL')   { Set-Final 'FAIL'   $msg }
}
# ---------- animation loop (~33 fps) ----------
$anim = New-Object Windows.Forms.Timer; $anim.Interval = 30
$anim.Add_Tick({
    if ($form.Opacity -lt 0.97) { $form.Opacity = [Math]::Min(0.97, $form.Opacity + 0.08) }
    $script:cur += ($script:target - $script:cur) * 0.10
    if ([Math]::Abs($script:target - $script:cur) -lt 0.05) { $script:cur = $script:target }
    $script:shim += 7; if ($script:shim -gt $bar.Width + 40) { $script:shim = -120 }
    $lblPct.Text = ('{0}%' -f [int][Math]::Round($script:cur))
    $bar.Invalidate()
    $script:pollMs += $anim.Interval
    if ($script:pollMs -ge 1000) {
        $script:pollMs = 0
        if (-not $script:done) {
            $lblTime.Text = 'Elapsed  ' + $sw.Elapsed.ToString('mm\:ss')
            Read-Status
        } else {
            $left = $CloseAfterSec - [int]($sw.Elapsed - $script:doneAt).TotalSeconds
            $txt = "Closing in $([Math]::Max(0,$left))s"
            if ($script:finalHint) { $txt = $script:finalHint + '  -  ' + $txt }
            $lblHint.Text = $txt
            if ($left -le 0) { $anim.Stop(); $form.Close() }
        }
        if ($sw.Elapsed.TotalMinutes -gt $SafetyMins) { $anim.Stop(); $form.Close() }
    }
})
$form.Add_Shown({
    try { $v = 2; [BFNative]::DwmSetWindowAttribute($form.Handle, 33, [ref]$v, 4) | Out-Null } catch {}
    Read-Status
    $anim.Start()
})
$form.Add_FormClosed({ $anim.Stop(); $notify.Visible = $false; $notify.Dispose(); $script:mtx.ReleaseMutex() })
[void]$form.ShowDialog()

yes, you can create it directly within the BigFix Action Script using createfile until EOF, so there's no need to deploy it separately.

Shared.

This is already covered in the Action Script. Use override run with runas=currentuser rather than wait, so the UI launches without blocking the main action.

``
override run
runas=currentuser
hidden=true
run powershell.exe -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\ProgramData\BFProgress\Show-Progress.ps1"

The Action Script I shared in my earlier post is already a basic example for testing the progress UI. Now that I've provided the missing PowerShell script, you should have everything needed to test it.

Simply update the status file before each installation step, for example: Preparing (5%) → Closing application (20%) → Installing (40%) → Finalizing (90%) → Completed (100%).

Use the installer's actual exit code rather than relying on predefined percentages.

override wait
hidden=true
timeout_seconds=1800
disposition=terminate
wait msiexec.exe /i "__Download\app.msi" /qn /norestart
parameter "rc" = "{if exist exit code of action then exit code of action as string else "-1"}"

Based on the exit code, update the status file accordingly:
0 → 100|Completed
3010 → REBOOT|Installation completed. Restart required
Any other code, including a timeout → FAIL|Installation failed

You can then use exit {parameter "rc"} to return the installer result to BigFix.

I would recommend using BigFix's native Post-Action → Restart computer after action completes functionality rather than building separate restart controls into the PowerShell UI.

1 Like