trashy Posted March 20, 2014 Posted March 20, 2014 (edited) New Name Easy_DISM Since I started this project a couple years ago it has turned into something I can be proud of .Project Page Download Page I put this together in a couple hours but I ran ino a snag. My first question has to be is ListView the correct Function. My problem is the return value of the selected List View Item. List View Item 1 return value = 0 item 2 = 1 etc... As a work around I started with 0 but there is no image index 0 in a wim file. I need Item 1 to return a value of 1, item 2 = 2 etc... I hope this makes sense. Also ListView is just big enough to show 1 item, is it possible to auto select the Listview Item showing. I added a couple notes, lines I'm concerned with are 25 thru 30 expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("DISM GUI", 615, 438, 192, 124) $Label1 = GUICtrlCreateLabel("Wim File", 40, 32, 56, 17) $Label2 = GUICtrlCreateLabel("Mount Folder", 40, 96, 65, 17) $Label3 = GUICtrlCreateLabel("Image Index", 40, 168, 60, 17) $Label4 = GUICtrlCreateLabel("Mount", 180, 148, 56, 17) $Label5 = GUICtrlCreateLabel("Comit", 280, 148, 56, 17) $Label6 = GUICtrlCreateLabel("Discard", 380, 148, 56, 17) $Label7 = GUICtrlCreateLabel("Clean Corrupt Mount Points", 20, 384, 80, 27) $Input1 = GUICtrlCreateInput("", 40, 48, 401, 32) $Input2 = GUICtrlCreateInput("", 40, 112, 401, 32) $Button1 = GUICtrlCreateButton("Browse", 480, 56, 75, 25) $Button2 = GUICtrlCreateButton("Browse", 480, 120, 75, 25) $Button3 = GUICtrlCreateButton("Mount", 160, 168, 75, 25) $Button4 = GUICtrlCreateButton("UnMount", 260, 168, 75, 25) $Button5 = GUICtrlCreateButton("UnMount", 360, 168, 75, 25) $Button6 = GUICtrlCreateButton("Clean", 100, 384, 75, 25) $Button7 = GUICtrlCreateButton("Exit", 264, 384, 75, 25) $listview = GUICtrlCreateListView(" ",105, 168, 50, 25, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SINGLESEL,$LVS_NOCOLUMNHEADER )) _GUICtrlListView_AddItem($listview, "0") ;I need to get rid of this item _GUICtrlListView_AddItem($listview, "1") ;how to get a return value of 1 to pass to $iIndex on line 46 _GUICtrlListView_AddItem($listview, "2") ;how to get a return value of 2 to pass to $iIndex on line 46 _GUICtrlListView_AddItem($listview, "3") _GUICtrlListView_AddItem($listview, "4") _GUICtrlListView_AddItem($listview, "5") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button7 Exit Case $Button1 $of_Button1 = FileOpenDialog("Select WIM File : ", @HomeDrive, "WIM Files (*.wim)", 1, "") GUICtrlSetData($Input1, $of_Button1) Case $Button2 $of_Button2 = FileSelectFolder("Select Mount Folder", "") GUICtrlSetData($Input2, $of_Button2) Case $Button3 $iIndex = _GUICtrlListView_GetSelectedIndices($listview) RunWait("Dism.exe /Mount-Wim /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex) & " /MountDir:" & (GUICtrlRead($Input2)))) Case $Button4 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /commit")) Case $Button5 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /discard")) Case $Button6 Run(@ComSpec & " /c Dism.exe /Cleanup-wim && Pause") EndSwitch WEnd Edited January 20, 2017 by trashy New Name New Version
trashy Posted March 20, 2014 Author Posted March 20, 2014 Ok let me rephrase this. I know I can't change the return value. What I really need to do is pass the ListViewItem text to $iIndex
trashy Posted March 20, 2014 Author Posted March 20, 2014 Solved one problem once I found the right function $iIndex = _GUICtrlListView_GetItemTextString($listview) Now is it possible to set focus on ListView Item showing.
antmar904 Posted March 21, 2014 Posted March 21, 2014 Use gimagex http://www.autoitscript.com/site/autoit-tools/gimagex/
trashy Posted March 21, 2014 Author Posted March 21, 2014 I do and have for years. Also use command line version for both dism and imagex depends on the situation.
iamtheky Posted March 21, 2014 Posted March 21, 2014 maybe add more functionality for the things DISM excels at like updating images offline (/add-package /add-driver). Â Currently it could be entirely replaced with imagex commands. and you could use the results of a file select and imagex /info to present only valid volume choices (or at least to build a check that will prevent execution if the choice is not valid) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
trashy Posted March 21, 2014 Author Posted March 21, 2014 I'm a total amateur with Autoit and I only started on this yesterday. I plan to add the functions you speak of and more but had to start with the basics. Only thing I found similar was here.http://dismgui.codeplex.com/releases/view/101865 I thought something better could be done in Autoit! Besides to someone like me it's a challenge. I was surprised no one in the Autoit community hadn't already attempted something. I'm trying to learn and I hope I'm beginning to understand. I know there are many here who could do better. If someone wants to take over, be my guest.
trashy Posted March 21, 2014 Author Posted March 21, 2014 (edited) Here's what I got so far. Next I want to populate an input with the wim info of the selected wim and index. Still trying to get auto select of visible ListViewText. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> $Form1 = GUICreate("DISM GUI", 615, 438, 192, 124) $Label1 = GUICtrlCreateLabel("Wim File", 40, 32, 56, 17) $Label2 = GUICtrlCreateLabel("Mount Folder", 40, 96, 65, 17) $Label3 = GUICtrlCreateLabel("Image Index", 40, 168, 60, 17) $Label4 = GUICtrlCreateLabel("Mount", 180, 148, 56, 17) $Label5 = GUICtrlCreateLabel("UnMount", 325, 148, 56, 17) $Label6 = GUICtrlCreateLabel("Clean Corrupt Mount Points", 20, 384, 80, 27) $Label7 = GUICtrlCreateLabel("Click the index number then click mount", 40, 200, 200, 17) ;gotta get rid of this $Input1 = GUICtrlCreateInput("", 40, 48, 401, 32) $Input2 = GUICtrlCreateInput("", 40, 112, 401, 32) $Button1 = GUICtrlCreateButton("Browse", 480, 56, 75, 25) $Button2 = GUICtrlCreateButton("Browse", 480, 120, 75, 25) $Button3 = GUICtrlCreateButton("Mount", 160, 168, 75, 25) $Button4 = GUICtrlCreateButton("Commit", 260, 168, 75, 25) $Button5 = GUICtrlCreateButton("Discard", 360, 168, 75, 25) $Button6 = GUICtrlCreateButton("Clean", 100, 384, 75, 25) $Button7 = GUICtrlCreateButton("Exit", 264, 384, 75, 25) $listview = GUICtrlCreateListView(" ",105, 168, 50, 25, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SINGLESEL,$LVS_NOCOLUMNHEADER )) _GUICtrlListView_AddItem($listview, "1") _GUICtrlListView_AddItem($listview, "2") _GUICtrlListView_AddItem($listview, "3") _GUICtrlListView_AddItem($listview, "4") _GUICtrlListView_AddItem($listview, "5") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button7 Exit Case $Button1 $of_Button1 = FileOpenDialog("Select WIM File : ", @HomeDrive, "WIM Files (*.wim)", 1, "") GUICtrlSetData($Input1, $of_Button1) Case $Button2 $of_Button2 = FileSelectFolder("Select Mount Folder", "") GUICtrlSetData($Input2, $of_Button2) Case $Button3 $iIndex = _GUICtrlListView_GetItemTextString($listview) RunWait(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex))) ;need to pass this info to gui and get rid of cmd console $1 = MsgBox(262144 + 4 + 32, "Wim Info", "You saw it ya wanna continue") If $1 = 6 Then RunWait("Dism.exe /Mount-Wim /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex) & " /MountDir:" & (GUICtrlRead($Input2)))) EndIf Case $Button4 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /commit")) Case $Button5 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /discard")) Case $Button6 Run(@ComSpec & " /c Dism.exe /Cleanup-wim && Pause") EndSwitch WEnd Edited March 21, 2014 by trashy
trashy Posted March 21, 2014 Author Posted March 21, 2014 I've accomplished everything I set out to. Replaced ListView with UpDown, that solved all problems with index selection. MsgBox displays Wim Info, warnings if wim file or mount folder not provided. It was really looking sweet and then I discovered a major glitch. I always work from root directory, especially when dealing with large files. It wasn't untill I stared browsing for another wim file That I discovered this problem. It will only work from root directory, Wim file can only be inside 1 folder no sub dir. Doesn't matter where dismgui.exe is located. This has got me baffled, what would cause something like this. Dism commandline works without a hitch. I seriously need some HELP with this one. That's it, the script was working great but without the capability to get a wim file from any sub directory makes it all pretty worthless! Help me Please. DISMGUI expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #AutoIt3Wrapper_Run_Tidy=y #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <SendMessage.au3> #include <Constants.au3> #include <UpdownConstants.au3> $Form1 = GUICreate("DISM GUI", 615, 438, 192, 124) $Label1 = GUICtrlCreateLabel("Wim File", 40, 45, 56, 17) $Label2 = GUICtrlCreateLabel("Mount Folder", 40, 96, 65, 17) $Label3 = GUICtrlCreateLabel("Image Index", 40, 168, 60, 17) $Label4 = GUICtrlCreateLabel("Mount", 180, 148, 56, 17) $Label5 = GUICtrlCreateLabel("UnMount", 325, 148, 56, 17) $Label6 = GUICtrlCreateLabel("Clean Corrupt Mount Points", 20, 384, 80, 27) $Input1 = GUICtrlCreateInput("", 40, 60, 401, 25) $Input2 = GUICtrlCreateInput("", 40, 112, 401, 25) $input3 = GUICtrlCreateInput("1", 105, 168, 35, 20) GUICtrlCreateUpdown($input3) GUICtrlSetLimit(-1, 10, 1) $Button1 = GUICtrlCreateButton("Browse", 480, 60, 75, 25) $Button2 = GUICtrlCreateButton("Browse", 480, 112, 75, 25) $Button3 = GUICtrlCreateButton("Mount", 160, 168, 75, 25) $Button4 = GUICtrlCreateButton("Commit", 260, 168, 75, 25) $Button5 = GUICtrlCreateButton("Discard", 360, 168, 75, 25) $Button6 = GUICtrlCreateButton("Clean", 100, 384, 75, 25) $Button7 = GUICtrlCreateButton("Exit", 264, 384, 75, 25) $listview1 = GUICtrlCreateListView("", 40, 220, 500, 150) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button7 Exit Case $Button1 $of_Button1 = FileOpenDialog("Select WIM File : ", @HomeDrive, "WIM Files (*.wim)", 1, "") GUICtrlSetData($Input1, $of_Button1) ;~ ================================================================================================================ ;~ I want to populate $listview1 with info from $tOutput instead of $1 MsgBox ;~ ================================================================================================================ $aRun = Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & (GUICtrlRead($Input1)), "", @SW_SHOW, $STDOUT_CHILD) $tOutput = "" While 1 $tOutput &= StdoutRead($aRun) If @error Then ExitLoop Sleep(50) WEnd GUICtrlCreateListViewItem($tOutput, $listview1) $1 = MsgBox(262144, "Wim Info", $tOutput) ;~ ================================================================================================================ ;~ I want to populate $listview1 with info from $tOutput instead of $1 MsgBox ;~ ================================================================================================================ Case $Button2 $of_Button2 = FileSelectFolder("Select Mount Folder", "") GUICtrlSetData($Input2, $of_Button2) Case $Button3 If GUICtrlRead($Input1) = "" Then MsgBox(0, "Empty.....", "No WIM File Selected!") ContinueLoop EndIf If GUICtrlRead($Input2) = "" Then MsgBox(0, "Empty.....", "No Mount Folder Selected!") ContinueLoop EndIf $iIndex = GUICtrlRead($input3) $hRun = Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex)), "", @SW_SHOW, $STDOUT_CHILD) $sOutput = "" While 1 $sOutput &= StdoutRead($hRun) If @error Then ExitLoop Sleep(50) WEnd $2 = MsgBox(262144 + 4 + 32, "Wim Info", $sOutput & @CRLF & "Do you wish to continue?") If $2 = 6 Then RunWait("Dism.exe /Mount-Wim /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex) & " /MountDir:" & (GUICtrlRead($Input2)))) EndIf Case $Button4 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /commit")) Case $Button5 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /discard")) Case $Button6 Run(@ComSpec & " /c Dism.exe /Cleanup-wim && Pause") EndSwitch WEnd
iamtheky Posted March 21, 2014 Posted March 21, 2014 (edited) I would bet a dollar it is an issue with spaces in the path, not an issue with subdirectories. Â Use this for case 3 Case $Button3 $iIndex = _GUICtrlListView_GetSelectedIndices($listview) msgbox(0, '' , 'RunWait("Dism.exe /Mount-Wim /WimFile:"' & GUICtrlRead($Input1) & '" /index:"' & $iIndex & '" /MountDir:"' & GUICtrlRead($Input2)) Â you will see in the msgbox that the result of your command...is not so much a command when spaces are involved, Â also it does not appear that $iIndex is doing what you think it is. Â If it is just a variable then the parentheses are unnecessary. Â Also, the functions do not go in parentheses (though it seemingly worked fine), just the arguments - I fixed the cosmetics, take a stab at the spacing as it is good to learn to use a mixture of single and double quotes to accomplish your desired needs. Â And use msgbox or consolewrite to debug. Edited March 21, 2014 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
trashy Posted March 22, 2014 Author Posted March 22, 2014 I was thinking along the same lines as bothose and was trying every combination possible of quotes. Lets focus on Case $Button1 I started deactivating lines, functions , one by one untill I found the problem. I deactivated the line for FileOpenDialog function and typed C:X17-24394sourcesboot.wim into $Input1 box and it worked. Enter any path.wim in input box manually and it works every time. Have I not applied the FileOpenDialog function correctly or what. HELP! All this time I thought it was error in my run command syntax. I added a bunch of side notes as to what function did what and what I thought the problem was expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <SendMessage.au3> #include <Constants.au3> $Form1 = GUICreate("DISM GUI", 615, 438, 192, 124) $Label1 = GUICtrlCreateLabel("Wim File", 40, 45, 56, 17) $Label2 = GUICtrlCreateLabel("Mount Folder", 40, 96, 65, 17) $Label3 = GUICtrlCreateLabel("Image Index", 40, 168, 60, 17) $Label4 = GUICtrlCreateLabel("Mount", 180, 148, 56, 17) $Label5 = GUICtrlCreateLabel("UnMount", 325, 148, 56, 17) $Label6 = GUICtrlCreateLabel("Clean Corrupt Mount Points", 20, 384, 80, 27) $Input1 = GUICtrlCreateInput("", 40, 60, 401, 25) ;Displays complete path and .wim $Input2 = GUICtrlCreateInput("", 40, 112, 401, 25) ;Displays mount folder $input3 = GUICtrlCreateInput("1", 105, 168, 35, 20) ;Displays index number from UpDown GUICtrlCreateUpdown($input3) ;UpDown select image index GUICtrlSetLimit(-1, 10, 1) $Button1 = GUICtrlCreateButton("Browse", 480, 60, 75, 25) ;Browse for .wim file $Button2 = GUICtrlCreateButton("Browse", 480, 112, 75, 25) ;Browse for mount folder $Button3 = GUICtrlCreateButton("Mount", 160, 168, 75, 25) ;Mount $Button4 = GUICtrlCreateButton("Commit", 260, 168, 75, 25) $Button5 = GUICtrlCreateButton("Discard", 360, 168, 75, 25) $Button6 = GUICtrlCreateButton("Clean", 100, 384, 75, 25) $Button7 = GUICtrlCreateButton("Exit", 264, 384, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button7 Exit Case $Button1 ;$of_Button1 = FileOpenDialog("Select WIM File : ", @HomeDrive, "WIM Files (*.wim)", 1) ;Opens explore To search For wim file ;Required for line 39 t0 w0rk ;GUICtrlSetData($Input1, $of_Button1) ;Sends full path.wim to $Input1 ;Required for line 39 t0 w0rk Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & GUICtrlRead($Input1)) ;This only works in root of drive or 1 folder no sub directories, displays wim info in cmd console ;Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:C:\X17-24394\sources\boot.wim") ;This works displays wim info in cmd console as long as full path and wim are defined with no variables ; ~ The function below is to pass wim info from cmd console to $1 = MsgBox and hide cmd console and is not part of the problem ~ ; ;$aRun = Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & GUICtrlRead($Input1), "", @SW_SHOW, $STDOUT_CHILD) ;$tOutput = "" ;While 1 ;$tOutput &= StdOutRead($aRun) ;If @error Then ExitLoop ;Sleep(50) ;WEnd ;$1 = MsgBox(262144, "Wim Info", $tOutput) Case $Button2 $of_Button2 = FileSelectFolder("Select Mount Folder", "") GUICtrlSetData($Input2, $of_Button2) Case $Button3 If GuiCtrlRead($input1) = "" Then MsgBox (0,"Empty.....", "No WIM File Selected!") ContinueLoop EndIf If GuiCtrlRead($input2) = "" Then MsgBox (0,"Empty.....", "No Mount Folder Selected!") ContinueLoop EndIf $iIndex = GUICtrlRead($input3) $hRun = Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex)), "", @SW_SHOW, $STDOUT_CHILD) $sOutput = "" While 1 $sOutput &= StdOutRead($hRun) If @error Then ExitLoop Sleep(50) WEnd $2 = MsgBox(262144 + 4 + 32, "Wim Info", $sOutput & @CRLF & "Do you wish to continue?") If $2 = 6 Then RunWait("Dism.exe /Mount-Wim /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex) & " /MountDir:" & (GUICtrlRead($Input2)))) EndIf Case $Button4 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /commit")) Case $Button5 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /discard")) Case $Button6 Run(@ComSpec & " /c Dism.exe /Cleanup-wim && Pause") EndSwitch WEnd
iamtheky Posted March 22, 2014 Posted March 22, 2014 (edited) expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <SendMessage.au3> #include <Constants.au3> $Form1 = GUICreate("DISM GUI", 615, 438, 192, 124) $Label1 = GUICtrlCreateLabel("Wim File", 40, 45, 56, 17) $Label2 = GUICtrlCreateLabel("Mount Folder", 40, 96, 65, 17) $Label3 = GUICtrlCreateLabel("Image Index", 40, 168, 60, 17) $Label4 = GUICtrlCreateLabel("Mount", 180, 148, 56, 17) $Label5 = GUICtrlCreateLabel("UnMount", 325, 148, 56, 17) $Label6 = GUICtrlCreateLabel("Clean Corrupt Mount Points", 20, 384, 80, 27) $Input1 = GUICtrlCreateInput("", 40, 60, 401, 25) ;Displays complete path and .wim $Input2 = GUICtrlCreateInput("", 40, 112, 401, 25) ;Displays mount folder $input3 = GUICtrlCreateInput("1", 105, 168, 35, 20) ;Displays index number from UpDown GUICtrlCreateUpdown($input3) ;UpDown select image index GUICtrlSetLimit(-1, 10, 1) $Button1 = GUICtrlCreateButton("Browse", 480, 60, 75, 25) ;Browse for .wim file $Button2 = GUICtrlCreateButton("Browse", 480, 112, 75, 25) ;Browse for mount folder $Button3 = GUICtrlCreateButton("Mount", 160, 168, 75, 25) ;Mount $Button4 = GUICtrlCreateButton("Commit", 260, 168, 75, 25) $Button5 = GUICtrlCreateButton("Discard", 360, 168, 75, 25) $Button6 = GUICtrlCreateButton("Clean", 100, 384, 75, 25) $Button7 = GUICtrlCreateButton("Exit", 264, 384, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button7 Exit Case $Button1 $of_Button1 = FileOpenDialog("Select WIM File : ", @HomeDrive, "ANY Files (*.*)", 1) ;Opens explore To search For wim file ;Required for line 39 t0 w0rk GUICtrlSetData($Input1, $of_Button1) ;Sends full path.wim to $Input1 ;Required for line 39 t0 w0rk msgbox(0,'' , GUICtrlRead($input1)) run("cmd /k icacls " & GUICtrlRead($input1)) run("cmd /k icacls " & '"' & GUICtrlRead($input1) & '"') ;~ Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & GUICtrlRead($Input1)) ;This only works in root of drive or 1 folder no sub directories, displays wim info in cmd console ;~ Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:C:\X17-24394\sources\boot.wim") ;This works displays wim info in cmd console as long as full path and wim are defined with no variables ; ~ The function below is to pass wim info from cmd console to $1 = MsgBox and hide cmd console and is not part of the problem ~ ; ;$aRun = Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & GUICtrlRead($Input1), "", @SW_SHOW, $STDOUT_CHILD) ;$tOutput = "" ;While 1 ;$tOutput &= StdOutRead($aRun) ;If @error Then ExitLoop ;Sleep(50) ;WEnd ;$1 = MsgBox(262144, "Wim Info", $tOutput) Case $Button2 $of_Button2 = FileSelectFolder("Select Mount Folder", "") GUICtrlSetData($Input2, $of_Button2) Case $Button3 If GuiCtrlRead($input1) = "" Then MsgBox (0,"Empty.....", "No WIM File Selected!") ContinueLoop EndIf If GuiCtrlRead($input2) = "" Then MsgBox (0,"Empty.....", "No Mount Folder Selected!") ContinueLoop EndIf $iIndex = GUICtrlRead($input3) $hRun = Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex)), "", @SW_SHOW, $STDOUT_CHILD) $sOutput = "" While 1 $sOutput &= StdOutRead($hRun) If @error Then ExitLoop Sleep(50) WEnd $2 = MsgBox(262144 + 4 + 32, "Wim Info", $sOutput & @CRLF & "Do you wish to continue?") If $2 = 6 Then RunWait("Dism.exe /Mount-Wim /WimFile:" & (GUICtrlRead($Input1) & " /index:" & ($iIndex) & " /MountDir:" & (GUICtrlRead($Input2)))) EndIf Case $Button4 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /commit")) Case $Button5 RunWait("Dism.exe /UnMount-Wim /MountDir:" & (GUICtrlRead($Input2) & " /discard")) Case $Button6 Run(@ComSpec & " /c Dism.exe /Cleanup-wim && Pause") EndSwitch WEnd so hit your browse button. Select a file with spaces in a sub folder with spaces. *your read is fine as shown by msgbox one command window will fail and one will succeed. Â Im guessing wrapping your reads similarly may fix your issue. Edited March 22, 2014 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
trashy Posted March 22, 2014 Author Posted March 22, 2014 Folder and File names can not contain spaces, that's old school, wasn't the problem. Your script wasn't returning the desired info about the images inside the wim file. This was really getting mind boggling. It has nothing to do with dir and sub dir. Process for manipulating Wim files, Extract Windows Install files from iso or dvd to folder on hard drive. Wim location in sources folder and guess what else is located in that folder among a hundred other files. DISM.EXE. As soon as I got rid of it script runs flawlessly. DAMÂ I did all my testing on a single boot.wim extracted to the root of C drive so I didn't have a problem till I started browsing for other wim files. Kick me, beat me like a step child whatever. Now just to figure out how to get around dism conflict, can't permanently delete. Thanks boththose I took your advice and removed parentheses from functions. Next is to set tabs and start working on other dism functions. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <SendMessage.au3> #include <Constants.au3> $Form1 = GUICreate("DISM GUI", 615, 438, 192, 124) $Label1 = GUICtrlCreateLabel("Wim File", 40, 45, 56, 17) $Label2 = GUICtrlCreateLabel("Mount Folder", 40, 96, 65, 17) $Label3 = GUICtrlCreateLabel("Image Index", 40, 168, 60, 17) $Label4 = GUICtrlCreateLabel("Mount", 180, 148, 56, 17) $Label5 = GUICtrlCreateLabel("UnMount", 325, 148, 56, 17) $Label6 = GUICtrlCreateLabel("Clean Corrupt Mount Points", 20, 384, 80, 27) $Input1 = GUICtrlCreateInput("", 40, 60, 401, 25) $Input2 = GUICtrlCreateInput("", 40, 112, 401, 25) $input3 = GUICtrlCreateInput("1", 105, 168, 35, 20) GUICtrlCreateUpdown($input3) GUICtrlSetLimit(-1, 10, 1) $Button1 = GUICtrlCreateButton("Browse", 480, 60, 75, 25) $Button2 = GUICtrlCreateButton("Browse", 480, 112, 75, 25) $Button3 = GUICtrlCreateButton("Mount", 160, 168, 75, 25) $Button4 = GUICtrlCreateButton("Commit", 260, 168, 75, 25) $Button5 = GUICtrlCreateButton("Discard", 360, 168, 75, 25) $Button6 = GUICtrlCreateButton("Clean", 100, 384, 75, 25) $Button7 = GUICtrlCreateButton("Exit", 264, 384, 75, 25) $listview1 = GUICtrlCreateListView("", 40, 220, 500, 150) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button7 Exit Case $Button1 $of_Button1 = FileOpenDialog("Select WIM File : ", @HomeDrive, "WIM Files (*.wim)", 1, "") GUICtrlSetData($Input1, $of_Button1) ;~ ================================================================================================================ ;~ I want to populate $listview1 with info from $tOutput instead of $1 MsgBox ;~ ================================================================================================================ $aRun = Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & GUICtrlRead($Input1), "", @SW_SHOW, $STDOUT_CHILD) $tOutput = "" While 1 $tOutput &= StdOutRead($aRun) If @error Then ExitLoop Sleep(50) WEnd $1 = MsgBox(262144, "Wim Info", $tOutput) ;~ ================================================================================================================ ;~ I want to populate $listview1 with info from $tOutput instead of $1 MsgBox ;~ ================================================================================================================ Case $Button2 $of_Button2 = FileSelectFolder("Select Mount Folder", "") GUICtrlSetData($Input2, $of_Button2) Case $Button3 If GuiCtrlRead($input1) = "" Then MsgBox (0,"Empty.....", "No WIM File Selected!") ContinueLoop EndIf If GuiCtrlRead($input2) = "" Then MsgBox (0,"Empty.....", "No Mount Folder Selected!") ContinueLoop EndIf $iIndex = GUICtrlRead($input3) $hRun = Run(@ComSpec & " /k Dism.exe /Get-WimInfo /WimFile:" & GUICtrlRead($Input1) & " /index:" & $iIndex, "", @SW_SHOW, $STDOUT_CHILD) $sOutput = "" While 1 $sOutput &= StdOutRead($hRun) If @error Then ExitLoop Sleep(50) WEnd $2 = MsgBox(262144 + 4 + 32, "Wim Info", $sOutput & @CRLF & "Do you wish to continue?") If $2 = 6 Then RunWait("Dism.exe /Mount-Wim /WimFile:" & GUICtrlRead($Input1) & " /index:" & $iIndex & " /MountDir:" & (GUICtrlRead($Input2))) EndIf Case $Button4 RunWait("Dism.exe /UnMount-Wim /MountDir:" & GUICtrlRead($Input2) & " /commit") Case $Button5 RunWait("Dism.exe /UnMount-Wim /MountDir:" & GUICtrlRead($Input2) & " /discard") Case $Button6 Run(@ComSpec & " /c Dism.exe /Cleanup-wim && Pause") EndSwitch WEnd
iamtheky Posted March 22, 2014 Posted March 22, 2014 (edited) They can absolutely contain spaces, Are you saying there are still files of varying subdirectory and name, that cannot be executed because they are in a subdirectory or have spaces in the path? Â That is the only misunderstanding my example was trying to address. put a cmd /k before the dism commands and post screenshots of the command failing. Edited March 22, 2014 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
trashy Posted March 22, 2014 Author Posted March 22, 2014 What I meant was I never use spaces in folder names because it can cause conflicts. The cause of the conflict turned out to be dism.exe in the same folder that contained the wim file. I just used a cmd to rename it and problem solved. This only occur when using variables. Example: RunWait("Dism.exe /Mount-Wim /WimFile:" & GUICtrlRead($Input1) & " /index:" & GUICtrlRead($input3) & " /MountDir:" & GUICtrlRead($Input2)) If dism is in the same folder you got a problem. Example: RunWait("Dism /Mount-Wim /WimFile:C:NewfolderX17-24394sourcesboot.wim /index:1 /MountDir:C:mount2") This works doesn't mater if dism is in the same folder, solid cmd line no breaks everything enclosed in parentheses. I'm a dummy when it comes to dos cmd or any kind of script. I know k=keep but I had to look up cacls. Can't type worth a crap either. Those are the 2 biggest reasons I prefer using a GUI, hopefully I'll learn something along the way. Adding driver packs with dism is next thing I want to add. Thanks for your help.
trashy Posted March 23, 2014 Author Posted March 23, 2014 DISM ProgressBar I can successfully hide the console window and get the dism info to a msgbox but how to get the progress. #include <Constants.au3> $cRun = Run(@ComSpec & " /c Dism.exe /Mount-Wim /WimFile:C:\Newfolder\X17-24394\sources\boot.wim /index:1 /MountDir:C:\mount2", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($cRun, 2) $cOutput = StdoutRead($cRun) MsgBox(0, "Wim Mount", $cOutput) The only post I found concerning the subject: Using Mats Console.au3 got a ProgressBar to popup but didn't show any progress. Added driver pack install and tweaked script a little expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Run_Tidy=y #AutoIt3Wrapper_Tidy_Stop_OnError=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <SendMessage.au3> #include <Constants.au3> $Form1 = GUICreate("DISM GUI", 615, 440, 192, 124) $Label0 = GUICtrlCreateLabel("Mount Image", 270, 10, 65, 17) $Label1 = GUICtrlCreateLabel("Wim File", 40, 45, 56, 17) $Label2 = GUICtrlCreateLabel("Mount Folder", 40, 96, 65, 17) $Label3 = GUICtrlCreateLabel("Image Index", 40, 168, 60, 17) $Label4 = GUICtrlCreateLabel("Mount", 180, 148, 56, 17) $Label5 = GUICtrlCreateLabel("UnMount", 325, 148, 56, 17) $Label6 = GUICtrlCreateLabel("Clean Corrupt Mount Points", 20, 384, 80, 27) $Label7 = GUICtrlCreateLabel("Single Driver (.inf)", 40, 250, 85, 17) $Label8 = GUICtrlCreateLabel("Driver Folder (multi)", 40, 300, 90, 17) $Label9 = GUICtrlCreateLabel("Add drivers", 270, 230, 65, 17) $Input1 = GUICtrlCreateInput("", 40, 60, 401, 25) $Input2 = GUICtrlCreateInput("", 40, 112, 401, 25) $input3 = GUICtrlCreateInput("1", 105, 168, 35, 20) $input4 = GUICtrlCreateInput("", 40, 270, 401, 25) $input5 = GUICtrlCreateInput("", 40, 320, 401, 25) GUICtrlCreateUpdown($input3) GUICtrlSetLimit(-1, 10, 1) $Button1 = GUICtrlCreateButton("Browse", 480, 60, 75, 25) $Button2 = GUICtrlCreateButton("Browse", 480, 112, 75, 25) $Button3 = GUICtrlCreateButton("Mount", 160, 168, 75, 25) $Button4 = GUICtrlCreateButton("Commit", 260, 168, 75, 25) $Button5 = GUICtrlCreateButton("Discard", 360, 168, 75, 25) $Button6 = GUICtrlCreateButton("Clean", 100, 384, 75, 25) $Button7 = GUICtrlCreateButton("Exit", 264, 384, 75, 25) $Button8 = GUICtrlCreateButton("Browse", 480, 270, 75, 25) $Button9 = GUICtrlCreateButton("Browse", 480, 320, 75, 25) GUISetState(@SW_SHOW) _AddVertSep(10, 10, 200, $SS_ETCHEDFRAME) _AddHorzSep(10, 210, 550, $SS_ETCHEDFRAME) Func _AddVertSep($iX, $iY, $iH, $SS_ETCHEDFRAME) GUICtrlCreateLabel("", $iX, $iY, 1, $iH, $SS_ETCHEDFRAME) EndFunc ;==>_AddVertSep Func _AddHorzSep($iX, $iY, $iW, $SS_ETCHEDFRAME) GUICtrlCreateLabel("", $iX, $iY, $iW, 1, $SS_ETCHEDFRAME) EndFunc ;==>_AddHorzSep While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button7 If FileExists("newdism.exe") Then $sFileOld = "newdism.exe" $sFileRenamed = "dism.exe" FileMove($sFileOld, $sFileRenamed) EndIf Exit Case $Button1 $of_Button1 = FileOpenDialog("Select WIM File : ", @HomeDrive, "WIM Files (*.wim)", 1, "") GUICtrlSetData($Input1, $of_Button1) If FileExists("dism.exe") Then $sFileOld = "dism.exe" $sFileRenamed = "newdism.exe" FileMove($sFileOld, $sFileRenamed) EndIf $aRun = Run(@ComSpec & " /c Dism.exe /Get-WimInfo /WimFile:" & GUICtrlRead($Input1), "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($aRun, 2) $aOutput = StdoutRead($aRun) MsgBox(262144, "Wim Info", $aOutput) Case $Button2 $of_Button2 = FileSelectFolder("Select Mount Folder", "") GUICtrlSetData($Input2, $of_Button2) Case $Button3 If GUICtrlRead($Input1) = "" Then MsgBox(0, "Empty.....", "No WIM File Selected!") ContinueLoop EndIf If GUICtrlRead($Input2) = "" Then MsgBox(0, "Empty.....", "No Mount Folder Selected!") ContinueLoop EndIf $bRun = Run(@ComSpec & " /c Dism.exe /Get-WimInfo /WimFile:" & GUICtrlRead($Input1) & " /index:" & GUICtrlRead($input3), "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($bRun, 2) $bOutput = StdoutRead($bRun) $2 = MsgBox(262144 + 4 + 32, "Wim Info", $bOutput & @CRLF & "Do you wish to continue?") If $2 = 6 Then RunWait("Dism.exe /Mount-Wim /WimFile:" & GUICtrlRead($Input1) & " /index:" & GUICtrlRead($input3) & " /MountDir:" & GUICtrlRead($Input2)) EndIf Case $Button4 RunWait("Dism.exe /UnMount-Wim /MountDir:" & GUICtrlRead($Input2) & " /commit") Case $Button5 RunWait("Dism.exe /UnMount-Wim /MountDir:" & GUICtrlRead($Input2) & " /discard") Case $Button6 Run(@ComSpec & " /c Dism.exe /Cleanup-wim && Pause") Case $Button8 If GUICtrlRead($Input2) = "" Then MsgBox(0, "Empty.....", "No Mount Folder Selected!") ContinueLoop EndIf $of_Button8 = FileOpenDialog("Select INF File : ", @HomeDrive, "INF Files (*.inf)", 1, "") GUICtrlSetData($input4, $of_Button8) If GUICtrlRead($Input2) = "" Then MsgBox(0, "Empty.....", "No Mount Folder Selected!") ContinueLoop EndIf RunWait(@ComSpec & " /k Dism.exe /Image:" & GUICtrlRead($Input2) & " /Add-Driver /Driver:" & GUICtrlRead($input4)) MsgBox(0, "Finished", "If you are satisfied with results" & @CRLF & "And finished injecting drivers" & @CRLF & "Click Commit above") ;Dism /Image:C:\test\offline /Add-Driver /Driver:C:\drivers\mydriver.inf Case $Button9 $of_Button9 = FileSelectFolder("Select Driver Folder", "") GUICtrlSetData($input5, $of_Button9) If GUICtrlRead($Input2) = "" Then MsgBox(0, "Empty.....", "No Mount Folder Selected!") ContinueLoop EndIf RunWait(@ComSpec & " /c Dism.exe /Image:" & GUICtrlRead($Input2) & " /Add-Driver /Driver:" & GUICtrlRead($input5) & " /Recurse & Pause") MsgBox(0, "Finished", "If you are satisfied with results" & @CRLF & "And finished injecting drivers" & @CRLF & "Click Commit above") ;Dism /Image:C:\test\offline /Add-Driver /Driver:c:\drivers /Recurse EndSwitch WEnd
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