Jump to content

DISM console progress using StdoutRead


RvdH
 Share

Recommended Posts

  • 4 months later...
  • 9 months later...

First off I want to say that this community is great.  I have been using AutoIT for years now and typically whenever I am having an issue a quick search through the forums yields the necessary solution.  I made an attempt to create a progress bar for DISM a year or so ago but was unsuccessful.  A recent requirement has brought me back to investigate.  I was still seeing the same results however this time during my troubleshooting I noticed my  command was actually being inserted into the CMD window's title.  By simply specifying the title explicitly I was able to resolve the issue.  I created this forum account simply because this is the first time I felt I have something to share that may help someone else in the future.

$wimfile = "C:\Windows\temp\boot.wim"
$targetpath = "D:\mount"
$percent = 0
$value = 0
$Title = "Bogus"


$DISMp = Run(@ComSpec & " /c title " & $Title & "|" & 'Dism.exe /mount-wim /wimfile:"' & $wimfile & '" /index:1 /mountdir:"' & $targetpath, "", "", 2 + 4)



ProgressOn("Image Load", "Deploying Image", "0 percent")
While ProcessExists($DISMp)
    $line = StdoutRead($DISMp, 5)
    If StringInStr($line, ".0%") Then
        $line1 = StringSplit($line, ".")
        $value = StringRight($line1[$line1[0] - 1], 2)
        $value = StringStripWS($value, 7)
    EndIf
    If $value == "00" Then $value = 100
    If @error Then ExitLoop
    Sleep(50)
    If $percent <> $value Then
        ProgressSet($value, "Deploying Image", "Boot.wim" & $value & "%")
        $percent = $value
    EndIf
    If $value = 100 Then ExitLoop
WEnd

ProgressOff()

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...