Jump to content

Dism Progress Bar


Recommended Posts

I've only found one post pertaining to this specifically and no real sollution.

Pieced together from script I found here on the forum, here's a couple of attempts I made without success.

This one dism actually mounts the image but the progress bar doesn't work

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Tidy=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>



$WIM_PATH = "C:\New folder\boot.wim"
$Mount_Point = "C:\mount"


;~ Let's capture the processID in order to grab the StdOut ...
Local $ProcessID = Run(@ComSpec & " /c Dism.exe /Mount-Wim /WimFile:""" & $WIM_PATH & """ /index:1 /MountDir:""" & $Mount_Point, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($ProcessID, 2)
$aOutput = StdoutRead($ProcessID)

;MsgBox(262144, "Wim Info", $aOutput)

;~ Reading the output from the processID
ProgressOn("Mount Wim", "Progress", $aOutput)

While 1
    $fCurLine = StdoutRead($ProcessID) ;~ I read what the ProcessID write to the console

    If @error Then ExitLoop ;~ Make sure to exit when the ProcessID is finished

    $fLines = StringSplit($fCurLine, @CRLF, 2) ;~ Splitting the result which can contain several lines
    For $fLine In $fLines ;~ Treating each line individually
        $fLine = StringStripWS(StringStripCR($fLine), 3) ;~ Cleaning up the current string
        If $fLine <> "" And StringRegExp($fLine, "\[\s*\d+%\s*\]", 0) Then ;~ I select only the lines containing a %
            $fPercentage = StringRegExpReplace($fLine, "^.*\[\s*(\d+)%\s*\].*$", "$1") ;~ Get the percentage with a regular expression
            ProgressSet(Int($fPercentage), $fLine) ;~ Finally apply the percentage to the progress bar and the text



        EndIf
    Next
WEnd
ProgressOff()

This one I get nothing but a quick flash of the progress bar

#include <Constants.au3>

ProgressOn("Progress CAB","Creating CAB")

$iPID = Run(@ComSpec & " /c Dism.exe /Mount-Wim /WimFile:C:\New folder\boot.wim /index:1 /MountDir:C:\mount, ", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

    While 1

        $sData = StdoutRead($iPID)
        If @error Then ExitLoop
        If StringInStr($sData, "flushing") = 0 Then
            $aData = StringSplit($sData, '%')
            $iPercent = Int($aData[1])
            ProgressSet($sData + 1)
            ProgressSet($sData, $iPercent & " percent")
        Else
            ProgressSet(100 , "Flushing")
        EndIf

        Sleep(10)

    WEnd

ProgressOff()

Has any one ever found a solution

Link to comment
Share on other sites

  • 1 year later...

Hey i think that you didnt add #requireadmin to your scripit add it at the top as dism needs administrator elevation to work if you dont do that you would get an error at stderrread and no data would got to stdread so add a #requireadmin at the top

#RequireAdmin ;Add it here
#include <Constants.au3>

ProgressOn("Progress CAB","Creating CAB")

$iPID = Run(@ComSpec & " /c Dism.exe /Mount-Wim /WimFile:C:\New folder\boot.wim /index:1 /MountDir:C:\mount, ", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

    While 1

        $sData = StdoutRead($iPID)
        If @error Then ExitLoop
        If StringInStr($sData, "flushing") = 0 Then
            $aData = StringSplit($sData, '%')
            $iPercent = Int($aData[1])
            ProgressSet($sData + 1)
            ProgressSet($sData, $iPercent & " percent")
        Else
            ProgressSet(100 , "Flushing")
        EndIf

        Sleep(10)

    WEnd

ProgressOff()

if your rest code is correct it would work if you wont add requireadmin it would ive you an error like this 

Error: 740

Elevated permissions are required to run DISM.
Use an elevated command prompt to complete these tasks.

Also check wether the location and file exists hope i helped you trashy if you need any more help feel free to ask 

 

Edited by Surya

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

Still not working for me in WinPE. Applying image is working but not the GUI progress bar!

Any idea?

#include <String.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Crypt.au3>
#include <Array.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <Constants.au3>

#RequireAdmin

;Function Deploy Wim
_DeployWim()


Func _DeployWim()
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ; Apply Wim Image with GUI Bar
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            $ApplicationSource = @ScriptDir
            $WIMPACKAGE_NAME = "Win10x64.wim"
            $DISM_PATH = $ApplicationSource & "\Imagex32\Dism.exe" ; <Path to imagex.exe>
            $PACKAGE_NAME = $ApplicationSource & "\WimFiles\" & $WIMPACKAGE_NAME ; <Path to your WIM package>
            $DRIVE_DEST = "w:\" ; <Drive Destination (i.e.: C:)>
            $SPLASH_TITLE = "Applying image ..." ; example "My Company Imaging"


        ProgressOn("Progress WIM","Apply WIM")

                    $iPID  = RunWait($DISM_PATH & " /Apply-Image /ImageFile:" & $PACKAGE_NAME & " /index:1 /ApplyDir:" & $DRIVE_DEST, "", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)
        While 1

                $sData = StdoutRead($iPID)
                If @error Then ExitLoop
                If StringInStr($sData, "Applying") = 0 Then
                    $aData = StringSplit($sData, '%')
                    $iPercent = Int($aData[1])
                    ProgressSet($sData + 1)
                    ProgressSet($sData, $iPercent & " percent")
                Else
                    ProgressSet(100 , "Applying")
                EndIf

                Sleep(10)

            WEnd

        ProgressOff()
EndFunc

 

Edited by tarvr
Link to comment
Share on other sites

Here is a code try test it:

#include <Console.au3>

_DeployWim()

Func _DeployWim()
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ; Apply Wim Image with GUI Bar
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ;Variables
        $ApplicationSource = @ScriptDir
        $WIMPACKAGE_NAME = "Win10-Prof-64bit-EN.wim"
        $IMAGEX_PATH = $ApplicationSource & "\Imagex32\Dism.exe" ; <Path to imagex.exe>
        $PACKAGE_NAME = $ApplicationSource & "\WimFiles\" & $WIMPACKAGE_NAME ; <Path to your WIM package>
        $DRIVE_DEST = "w:\" ; <Drive Destination (i.e.: C:)>
        $SPLASH_TITLE = "Applying image ..." ; example "My Company Imaging"

        $__gvKernel32 = DllOpen("kernel32.dll")

        Local $iPid = Run($IMAGEX_PATH & " /Apply-Image /ImageFile:" & $PACKAGE_NAME & " /index:1 /ApplyDir:" & $DRIVE_DEST, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

        ProcessWait($iPid)

        _Console_Attach($iPid)

        ; The width of the dism progress is 60 chars, 2 chars are brackets so 58 possible = signs.
        ; The percentage starts at 27 chars, and is right aligned in 6 chars (Always to 1dp).

        ProgressOn("Dism.exe", "...")
            While ProcessExists($iPid)
                $s = _Console_ReadOutputCharacter(-1, 5, 27, 5)
                ProgressSet(Execute(StringReplace($s, "=", "")))
            WEnd
        ProgressOff()

        _Console_Free()
    Exit
EndFunc


Func _Console_ReadConsoleOutputCharacter($hConsoleOutput, $nNumberOfCharsToRead, $iX, $iY, $fUnicode = Default, $hDll = -1)
    Local $tCoord, $tBuffer, $aResult

    If $fUnicode = Default Then $fUnicode = $__gfUnicode
    If $hDll = -1 Then $hDll = $__gvKernel32
    If $hConsoleOutput = -1 Then $hConsoleOutput = _Console_GetStdHandle($STD_OUTPUT_HANDLE, $hDll)

    $tCoord = BitShift($iY, -16) + $iX

    If $fUnicode Then
        $tBuffer = DllStructCreate("wchar[" & ($nNumberOfCharsToRead + 1) & "]")

        $aResult = DllCall($hDll, "bool", "ReadConsoleOutputCharacterW", _
                "handle", $hConsoleOutput, _
                "ptr", DllStructGetPtr($tBuffer), _
                "dword", $nNumberOfCharsToRead, _
                "dword", $tCoord, _
                "dword*", 0)
    Else
        $tBuffer = DllStructCreate("char[" & ($nNumberOfCharsToRead + 1) & "]")

        $aResult = DllCall($hDll, "bool", "ReadConsoleOutputCharacterA", _
                "handle", $hConsoleOutput, _
                "ptr", DllStructGetPtr($tBuffer), _
                "dword", $nNumberOfCharsToRead, _
                "dword", $tCoord, _
                "dword*", 0)
    EndIf
    If @error Or (Not $aResult[0]) Then Return SetError(@error, @extended, "")

    Return SetExtended($aResult[4], DllStructGetData($tBuffer, 1))
EndFunc   ;==>_Console_ReadConsoleOutputCharacter

This thread may help you https://www.autoitscript.com/forum/topic/123970-dism-console-progress-using-stdoutread/ if you still didnt get what you want ask me i will convert the code for you and console.au3 here http://code.google.com/p/consoleau3/ you could consider wimlib instead of dism for image manipulation here is itls link http://sourceforge.net/projects/wimlib/ feel free to ask for any more help

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

Thanks for helping but no luck.

I found already the other thread but is was not working for me.

Before I used imagex for deployment (with GUI bar), but with now with windows 10 I have problems with imagex and they suggest using dism what is working fine.

I tested your script under WinPE 3.1 but the progress bar bar is not working. The DISM Wim deployment itself was done!

Any suggestion?

Link to comment
Share on other sites

I did some research and some tests but still no success.

If you run the “dism” command from a DOS box you can see the Percentage of the progress.

Is there a way to read this percentage number and used this to create the GUI progress bar?

Link to comment
Share on other sites

I remember having success with rtconsole for imagex, i would guess that DISM flushes in the same manner.

http://www.codeproject.com/Articles/16163/Real-Time-Console-Output-Redirection#solution

 

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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...