trashy Posted March 25, 2014 Posted March 25, 2014 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 expandcollapse popup#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
Surya Posted August 23, 2015 Posted August 23, 2015 (edited) 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: 740Elevated 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 August 23, 2015 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)
tarvr Posted August 24, 2015 Posted August 24, 2015 (edited) Still not working for me in WinPE. Applying image is working but not the GUI progress bar!Any idea?expandcollapse popup#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 August 24, 2015 by tarvr
Surya Posted August 24, 2015 Posted August 24, 2015 Here is a code try test it:expandcollapse popup#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_ReadConsoleOutputCharacterThis 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)
tarvr Posted August 24, 2015 Posted August 24, 2015 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?
Surya Posted August 24, 2015 Posted August 24, 2015 dont worry i am working on it 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)
Surya Posted August 24, 2015 Posted August 24, 2015 can i suggest you another method it works but is nasty just redirect the output from the run function read it using fileread command 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)
tarvr Posted August 26, 2015 Posted August 26, 2015 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?
iamtheky Posted August 26, 2015 Posted August 26, 2015 (edited) 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 August 26, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now