Track batch installation files

Welcome Forums General PowerShell Q&A Track batch installation files

This topic contains 3 replies, has 3 voices, and was last updated by

3 years, 10 months ago.

  • Author
  • #23816

    Points: 0
    Rank: Member

    Hi Everyone,

    I have a problem that I looked everywhere and couldn't find anything that can actually do what I'm after.

    I have to write a "framework" that installs, updates, etc. for my company. I'm doing this with PowerShell. However, I don't have control over the installation scripts which is written in batch files. They all are different groups and configure the software for the company needs.

    So what I'm trying to do is write a GUI PowerShell "framework" with a progress bar (using Sapien) that calls each batch file and tracks the process (hangs, completed, failed,etc.). on a different process or runspace to avoid freezing up the progress bar. If the application hangs, or fails just simply kill the process and continue to the next one.

    If tracking the batch file is not possible (from my searches so far seems like it) anyone has any ideas of how to accomplish what I'm trying to do a better or different way?

    Below is just a simple code to start. This works and calls each batch file but tracking them has been a pain for me.

    Thank you everyone in advance.

    $Logfile = "C:\Tmp\progress.log"
    $Appname = @("Adobe_FlashPlayer_01", ", "Acrobat_Reader_01 , "Scheduler_2.0" , "Microsoft_RDP_01")

    Function Get_AppList
    Param (
    [Parameter(Mandatory, ValueFromPipeline)]

    Process {
    cmd /c $Apps

    foreach ($app in $Appname)
    $Install = "C:\tmp\cmd\$App\Install.cmd"
    Invoke-Command -ScriptBlock {Get_Applist($Install)}

  • #23829

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    It depends on what you mean by "tracking." When PowerShell runs a batch file, it actually just runs Cmd.exe, and tells it to run the batch file. You can't get any tracking of what's happening inside that process. You get a return code when it exits, and you can capture whatever text the process outputs to StdOut. But you can't really "detect" a hung process, because PowerShell can't differentiate between "hung" and "still working."

    Understand that you're trying to code what is essentially a commercial software management solution. There's a reason folks pay other people for those tools :). I understand that your company might not want to, or be able to, buy a tool – but that doesn't mean coding it yourself is going to be easy, and it doesn't mean PowerShell is going to be the best way to go about it. This is System Center Configuration Manager-league stuff, or at the very least Group Policy-league stuff.

    Another problem you'll run into is that, in some cases, installers will fail if there's another installer that's recently run and wants a reboot. You're just running them all in sequence without managing that; if you've tested all your installers and you know that's okay, cool.

    ME... I'd pursue a completely different, preferably non-DIY approach, because application installation is a complex nightmare. Group Policy, maybe, if not a full application deployment solution. Coding that myself would take a long time, especially because a lot of these installers aren't well-written, so you end up in a hell on Earth of exceptions and edge cases. Other folks might have different suggestions; I know people do rub their noses on grindstones over application installs in PowerShell. I've just never felt that it was an especially efficient approach, in terms of my time.

  • #23832

    Points: 0
    Rank: Member

    As Don says, coding it yourself will be pretty hard, there is a PowerShell solution though: Unfortunately, I've no experience deploying batch files with the PowerShell App Deployment Toolkit, but you can execute custom processes using Execute-Process from the toolkit.

  • #23858

    Points: 0
    Rank: Member

    Thank you both for replies.

    I guess I have to go a different route like Don suggested.


    I'm going to take a look at that link you sent.

    Thank you both again.

The topic ‘Track batch installation files’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort