Jump to content
Sign in to follow this  
scubasteve1281

GUI in WINPE

Recommended Posts

scubasteve1281

I'm building a customized system restore using WINPE and Autoit. I made a Gui that is executed from the Winpeshl.ini file this gui gives a restore button a reboot button and a button that spawns cmd window. the problem I'm having is that the initial Gui is not being displayed in WINPE if I hit the default keys for restore process it will start the process and spawn the restore progress window and that window will be visible. The Gui script works just fine on a win7 box. I then created a dummy Gui and ran it in the WINPE environment it worked fine also so I'm not sure what is wrong with my script.

;This the GUI automation for restoration process

; Required includes for the GUI interface
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <SendMessage.au3>

;This creates the varibles required for the proccess
$varReboot = "x:\windows\system32\wpeutil.exe reboot" ; Var for reboot a sytem in side a win PE enviroment
$varGhostrestore = "x:\ghost\GHOST32.exe -clone,mode=prestore,src=e:\factory.GHO:1,dst=1:2 -sure -fx -RB -BLIND" ; this is the command that executes the ghost restore

;this installs the  icture fiels used in the GUI
FileInstall("C:\Ghost Recovery\GBThumb.jpg" , "")
FileInstall("C:\Ghost Recovery\GBcrazy.jpg" , "")

;this the main GUI page
#Region ### START Koda GUI section ### Form=c:\recovery\recoverygui.kxf
$Formmain = GUICreate("Recovery ", 610, 360, 1596, 142)
GUISetFont(12, 400, 0, "MS Sans Serif")
$Continue = GUICtrlCreateButton("Continue", 192, 304, 75, 25, 0)
GUICtrlSetColor(-1, 0xFF0000)
$Reboot = GUICtrlCreateButton("Reboot", 312, 304, 75, 25, 0)
GUICtrlSetColor(-1, 0xFF0000)
$Pic1 = GUICtrlCreatePic("C:\ Recovery\GBThumb.jpg", 0, 0, 609, 121, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("words ", 96, 136, 410, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel(" Recovery ", 136, 176, 336, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("The following  procedure will restore this computer to default settings  ", 24, 216, 561, 24)
$Label4 = GUICtrlCreateLabel("WARNING The operating system and any data on this system will be deleted", 16, 240, 566, 24)
GUICtrlSetColor(-1, 0xFF0000)
$Label5 = GUICtrlCreateLabel("Press continue to begin the restoral proccess", 112, 264, 394, 24)
$Fil = GUICtrlCreateMenu("&File")
$Admin = GUICtrlCreateMenuItem("Administration", $Fil)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;This creates the GUI for the YES/NO continueation
#Region ### START Koda GUI section ### Form=c:\recovery\recoverycontinue.kxf
$Formcontinue = GUICreate(" Proccess", 337, 123, 1620, 225)
$Yes = GUICtrlCreateButton("Yes", 72, 88, 75, 25, 0)
$No = GUICtrlCreateButton("No", 208, 88, 75, 25, 0)
$Label1 = GUICtrlCreateLabel("with system recovery", 80, 40, 209, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Are you sure you want to continue", 16, 8, 308, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
#EndRegion ### END Koda GUI section ###

;Creates the Loop that runs while main gui is active musted be called any time the main gui is used 
Func Main()
    While 1
    $nMsg = GUIGetMsg()
    ;If $nMsg=-3 Then Exit
    If $nMsg=$Reboot then Reboot1()
    If $nMsg=$Continue then Continue1()
    If $nMsg=$Admin then Admin1()
                Switch $nMsg
        Case $GUI_EVENT_CLOSE
    ;   Exit
    EndSwitch
WEnd

EndFunc

; this Function call for the reboot command
Func Reboot1()
        Run(@ComSpec & " /c " & $varReboot, "", @SW_HIDE)
    EndFunc
    
Func Continue1()
    GUISetState (@SW_SHOW, $Formcontinue)
While 1
    $nMsg = GUIGetMsg()
    If $nMsg=-3 Then No1()
    If $nMsg=$No then No1()
    If $nMsg=$Yes then Yes1()
            Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Main()
    EndSwitch
WEnd
EndFunc

Func Yes1()
    
        GUISetState(@SW_HIDE, $Formcontinue)
        GUISetState(@SW_HIDE, $Formmain)
            Run (@ComSpec & " /c " & $varGhostrestore, "", @SW_HIDE)    
    
    #Region ### START Koda GUI section ### Form=c:\ recovery\progress.kxf
$Formprogress = GUICreate("RProccess", 433, 266, -1, -1)
GUISetIcon("DIASUS.ico")
$Label1 = GUICtrlCreateLabel("The system is restoring this may take a while please do not reboot", 16, 184, 394, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatePic("RockwellSystemRecovery.bmp", 0, 0, 428, 172, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreateProgress(16, 216, 398, 41, $PBS_MARQUEE)
    _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms
    GUISetState()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
    
        
    While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

  EndFunc

 Func No1()
    GUISetState (@SW_HIDE, $Formcontinue)
    GUISetState (@SW_SHOW, $Formmain)
    Main()
    EndFunc

;this starts cmd
Func Admin1()
        Do
    $pass = InputBox ("Admin password", "Admin Password","","*",200,120,-1,-1)
    GUISetIcon("DIASUS.ico")
    If $pass<>"datapath"Then
        $msgbox=MsgBox (1,"Warning" , "Wrong Password",200,100)
        If $msgbox=2 Then
            ExitLoop
            Main()
        EndIf
    EndIf
Until $pass="datapath"
    Run ("X:\windows\system32\cmd.exe" ,"" , @SW_SHOW)
EndFunc

; this funtion refence the main loop  and allows for the main mune to operate
Main()

Share this post


Link to post
Share on other sites
Fire

Change this on your scipt

$Formmain = GUICreate("Recovery ", 610, 360, 1596, 142)

to:

$Formmain = GUICreate("Recovery ", 633, 447, 192, 124)

Now it wil be visible.


[size="5"] [/size]

Share this post


Link to post
Share on other sites
scubasteve1281

Change this on your scipt

$Formmain = GUICreate("Recovery ", 610, 360, 1596, 142)

to:

$Formmain = GUICreate("Recovery ", 633, 447, 192, 124)

Now it wil be visible.

wow I can't believe I missed that they should be -1, -1 so that it centers it

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.