Gui Progress bar calling batch files(Sapien)

I found this gui progress bar on a different site. The way that it explains, should solve my problem which when the job is running not let the gui freeze.

However, since I’m dealing with batch files (installing applications) I need to do a foreach app and install them one by one and not let the gui freeze.

Here is the link to the site link PowerShell Studio: Creating Responsive Forms – SAPIEN Blog

and here is what i’m trying to implement (this doesn’t work obviously)

$Appname = @("Adobe_FlashPlayer", "Acrobat_Reader", "Microsoft_RDP")
-JobScript {
    for($i = 0; $i -lt 100; $i++)
    { 
        Foreach($App in $Appname){
$Install = "C:\test\$App\Install.cmd"

}
        Start-Sleep -Milliseconds 100 

        $i + 1
    } 
}

… The script continues here with update and stop job
any help would be appreciated. Thanks.

The progress bar pictured in the forum is spawned from a .NET form. This article shows a bit more of what would be required: Add a Progress Bar to a Graphical Status Box in PowerShell -- Microsoft Certified Professional Magazine Online

It’s about 100 lines of code to create a form, set form properties, create form objects (label & progress) and then all of the code to do what the script is actually trying to accomplish with some math to manipulate the progress. You’ll notice that this script enumerating file and folders. With files and folders, we can easily get total counts and then do math to determine progress. With your code, you have 3 applications , so 33.3 when each application installs. What I’m alluding to, is you’re not showing much progress.

With that said, explain what you are trying to accomplish? Who is the progress for? Users or for you to see the progress of something you are doing.

There are other solutions to provide progress, such as Write-Progress, but it would help to have some background and what the goal is.

Hi,
Sorry I should’ve been more clear.

I have some batch files that are “packaged” within our company. Each batch file (ex. Adobe Reader) checks if there is an older version or new version it uninstalls first, configures some settings to match the company policy, etc. The department that writes these batch files is different and they insist of writing them in batch files. Sometimes I can have as little as 10 different applications to call, sometimes as much as 30. I just put the example for 3 in this case.

So what i’m trying to do is create a “framework” that calls each of these batch files and waits to install it then updates progress bar with an elapsed time then goes to the next batch file until it finishes all apps in the array. If the elapsed time reaches 60 minutes, i want it to kill all the process and report it as “failed”. This is for the users, so that they can see what is going on while the installations are going.

I was able to get it working the way I want except the elapsed time freezes every time an installation starts. Doing some search, I came across to this link PowerShell Studio: Creating Responsive Forms – SAPIEN Blog, But I’m kind of stuck implementing what I’m trying to do.

I’m new to scriptblocks and stuff so it just doesn’t make sense to me how to call batch files and push it to the “job” so that it updates the progress bar.

I kind of figured out how to call the batch files, but since ( and I’m guess thats the reason) I didn’t use the “job” inside the script block, it just calls everything at once and that causes all the installations to fail because the first one is still in the progress of installing.

Hope this is a little clear.

Thanks for your help.

Best.