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
  • 12,708
  • 2
  • 36
  • 40
Gus
  • 913
  • 2
  • 15
  • 30

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
  • 382,024
  • 64
  • 607
  • 775
JPBlanc
  • 70,406
  • 17
  • 130
  • 175