Elephant007 Posted January 24, 2011 Share Posted January 24, 2011 (edited) Here is a script I built, basically it runs in a Windows PE and reads from a list in a directory of available WIMs to image computers with The problem I am having is when you select the WIM to use, the window still stays open while the rest of the script runs, I would like for this window to close after the WIM is selected Here is my script. This script is called from a batch file that creates the list of available WIMS by using dir /b e:\Image > x:\windows\System32\dsk\images before the AutoIt executable runs expandcollapse popup#include <GUIConstantsEx.au3> #include <String.au3> Func Imaging() $Answer1 = InputBox ( 'Auto Imaging Process', 'Use this process to image client computers' & @CRLF & @CRLF & 'YES = Start auto imaging process' & @CRLF & 'EXIT = Exit to DOS' ) If $Answer1 = 'YES' Then Local $Menu1, $n1, $n2, $Msg, $Menustate, $Menutext, $File Local $Line, $Array = _StringExplode(FileRead('X:\Windows\System32\dsk\images'), @LF) For $i = 0 To UBound($Array) - 1 If StringRegExp($Array[$i], '(?i).[\d]+') Then $Line &= $Array[$i] & '|' Next $Line = StringRegExpReplace($Line, '[\s|]*$', '') ;trim spaces, returns, line breaks, and pipes from end of the string $Winder = GUICreate('Select Image to Use', 260, 250) ; will create a dialog box that when displayed is centered GUICtrlCreateLabel('Avaliable Images', 22, 10, 100) $n1 = GUICtrlCreateList('', 20, 30, 215, 150) GUICtrlSetData(-1, $Line) $n2 = GUICtrlCreateButton('Select This Image to Use', 28, 200, 200) GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button GUISetState() ; will display an empty dialog box ; Run the GUI until the dialog is closed Do $Msg = GUIGetMsg() If $Msg = $n2 Then ;Local $Disk = StringRegExpReplace(GUICtrlRead($n1), '(?i)^.*(. [\d]+).*$', '$1') Local $Image = GUICtrlRead($n1) Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(262452, 'Selected Image Is: ' & $Image, 'Proceed with Imaging ' & $Image & '?') Select Case $iMsgBoxAnswer = 6 ;Yes RunWait ( 'cmd /c ' & 'diskpart /s ' & 'X:\Windows\System32\dsk\prepdisk', '') RunWait ( 'cmd /c ' & 'X:\Windows\System32\imagex.exe /apply ' & '"E:\Image\' & $Image & '"' & ' 1 C:\', '' ) $Reboots = MsgBox ( 1, 'Done', 'Image process complete' & @CRLF & 'Reboot computer' ) Case $iMsgBoxAnswer = 7 ;No EndSelect EndIf Until $Msg = $GUI_EVENT_CLOSE ;If $Reboots = 1 Then Run ( 'cmd /c exit', @TempDir, @SW_HIDE ) EndIf If $Answer1 = 'exit' Then Exit If $Answer1 = -1 Then Exit EndFunc Imaging() Edited January 24, 2011 by Elephant007 Link to comment Share on other sites More sharing options...
Elephant007 Posted January 24, 2011 Author Share Posted January 24, 2011 Found it, I added this GUIDelete($Winder) To line 30 Link to comment Share on other sites More sharing options...
iamtheky Posted January 24, 2011 Share Posted January 24, 2011 Until $Msg = $GUI_EVENT_CLOSE or $iMsgboxAnswer in yours it keeps DOing UNTIL some $GUI_EVENT_CLOSEs ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
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