Search code examples
.netpowershell

Show progress in Windows Taskbar (Powershell)


I'm trying to figure out how to show progress on the taskbar. Via PowerShell.

enter image description here

As I understand it, I should use something like this:

$Progress = [System.Windows.Shell.TaskbarItemInfo]::New()

$Progress.ProgressState = 'Normal'
$Progress.ProgressValue = 0.3

But that does not work. What am I doing wrong? How to show progress on the taskbar? Thanks you


Solution

  • For those who are looking for an answer. As it turned out, the .NET Framework does not support show progress on the taskbar. Windows Forms also do not support this. It support on WPF now.

    However, there is a solution. The solution was written by Ravikanth Chaganti. https://www.ravichaganti.com/blog/programming-windows-7-taskbar-using-windows-api-code-pack-and-powershell/. To do this, you need to download and install WindowsAPICodePack library (it was intended for Windows 7).:

    Open PowerShell and load the assembly

    [Reflection.Assembly]::LoadFrom(“D:\API\Microsoft.WindowsAPICodePack.Shell.Dll”)

    Create a TaskBarManager instance

    $TaskBarObject = [Microsoft.WindowsAPICodePack.TaskBar.TaskBarManager]::Instance

    Set the ProgressBar state

    $TaskBarObject.SetProgressState(“Normal”)

    This is not mandatory. However, it is important to understand the possible values. Here is what each of the progress bar states mean:

    No Progress – No progress bar is displayed Indeterminate – The progress is indeterminate (marquee) Normal – Normal progress is displayed Error – An error occurred (red) Paused – The operation is paused (yellow)

    To set the progress bar value

    $TaskBarObject.SetProgressValue(50,100)