2

If I execute the script in the console the progress bar is shown perfectly, but if I convert the script to exe with ps2exe the progress bar is not shown.

How can I solve this issue? Thank you

$totalTimes = 10
$i = 0

for ($i=0;$i -lt $totalTimes; $i++) {
   $percentComplete = ($i / $totalTimes) * 100
   Write-Progress -Activity 'Doing thing' -Status "Did thing $i  times" -PercentComplete $percentComplete
   sleep 1
}
henrycarteruk
  • 11,908
  • 2
  • 32
  • 38
Gus
  • 893
  • 2
  • 14
  • 27

1 Answers1

4

Have you tried with PS2EXE-GUI?

It "converts" PowerShell scripts to EXE Files, optionally as GUI applications:

.\ps2exe.ps1 -noconsole -inputFile 'test.ps1' -outputFile 'test.exe' 

If test.ps1 contains your sample code, running .\test.exe will show a GUI progress bar such as the following:

enter image description here

mklement0
  • 312,089
  • 56
  • 508
  • 622
JPBlanc
  • 67,114
  • 13
  • 128
  • 165