Jump to content

Getting callbacks from gximage_com.dll or wimgapi.dll


CalBoy
 Share

Recommended Posts

I'm sorry if I use the incorrect terminology, but I will try my best! Any help is greatly appreciated!

Currently I am attempting to complete a GUI for a Windows 7 Deployment through WinPE, the last thing I need to do is finish off the progress bar for the actual applying of the WIM. Currently I am applying it via ImageX and getting the progress via comparing the amount of space taken up on the drive, this however can not work correctly some of the time and the computer restarts before the WIM has finished applying and its messy with a CMD window open, what I wish to do somehow is use gximage_com.dll or wimgapi.dll to apply my WIM, which would mean no CMD window.

So my actual question is, how would I go around putting one of these two dlls within the script and then get the call backs from them to update the progress bar?

Current progress bar script. (Thanks to M23 for helping me clean it up)

;finds the boot letter
$registry = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\", "PEBootRamdiskSourceDrive")

;applies the wim
$imagex = ShellExecute("imagex.exe", "/apply " & $registry & "sources\install.wim 1 H:\", @ScriptDir)

;minimises the command window
WinMinimizeAll()

;creates the slider
;Deletes previous UI
GUIDelete()
GUICreate("Progress Bar", 220, 100, (@DesktopWidth - 220) / 2, (@DesktopHeight - 100) / 2)
$progress = GUICtrlCreateProgress(10, 10, 200, 20, $PBS_SMOOTH)

$button = GUICtrlCreateButton("Percentage", 80, 65, 65, 25)
$labelprogress = GUICtrlCreateLabel(" Complete", 70, 40, 100, 15)
GUISetState()


Do
    ; Look for the button in this section
    $msg = GUIGetMsg()
    If $msg = $button Then
        MsgBox(64, "Percentage", $Percentage & "% Completed", 3)
    EndIf

    ; Update the progress in this section
    $Free = DriveSpaceFree("H:\")
    $total = DriveSpaceTotal("H:\")
    $taken = $total - $Free
    ;based on the total size of the wim which is 15802
    $Percentage = Round($taken / (15802 / 100), 0)
    GUICtrlSetData($progress, $Percentage + 1)
    GUICtrlSetData($progress, $Percentage)
    GUICtrlSetData($labelprogress, $Percentage & "% Completed")
    Sleep(50)


Until $Percentage >= 100

Thanks in advance for any help

CalBoy

Link to comment
Share on other sites

So I found some code in these forums and edited to to work with applying.

#include <ProgressConstants.au3> ; You need it, but I am sure you had it! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$objWIM = ObjCreate("GimageX.GimageXCtrl")
If Not IsObj($objWIM) Then
    Runwait("regsvr32.exe /s gimagex_com.dll")
    $objWIM = ObjCreate("GimageX.GimageXCtrl")
    If Not IsObj($objWIM) Then
        MsgBox(0, "Error", "$objWIM isn't a valid Object.")
        Exit
    EndIf
EndIf

$obj_evenement = ObjEvent($objWIM, "WimEvent_")
If @error Then
    MsgBox(0, "AutoIt COM Test", _
        "WimEvent have this error: " & Hex(@error, 8))
    Exit
EndIf

GUICreate("Progress Bar", 220, 100, (@DesktopWidth - 220) / 2, (@DesktopHeight - 100) / 2)
$progress = GUICtrlCreateProgress(10, 10, 200, 20, $PBS_SMOOTH)
$button = GUICtrlCreateButton("Percentage", 80, 65, 65, 25)
$labelprogress = GUICtrlCreateLabel(" Complete", 70, 40, 100, 15)

GUISetState()

With $objWIM
    .Source = "c:\boot.wim"
    .Destination = "c:\test2\"
    .ImageIndex = 1
    .Check = True
    .Verify = True
EndWith

ProgressOn("Compilation", "Compilation progression")
$objWIM.ApplyImage

Func WimEvent_Progress($Percent, $TimeRemaining)
    Do
        $msg = GUIGetMsg()
        If $msg = $button Then
        MsgBox(64, "Percentage", $Percent & "% Completed", 3)
        EndIf

    ; Update the progress in this section
        GUICtrlSetData($progress, $Percent + 1)
        GUICtrlSetData($progress, $Percent)
        GUICtrlSetData($labelprogress, $Percent & "% Completed")
    Until $Percent <= 100
EndFunc

Sleep(200000)

The problems with the code at the moment is that it hangs and doesn't update the progress correctly until the wim has finished applying and even then it only shows as 37% complete. Currently I am using gimagex_com.dll to apply the WIM. I am unsure whether it is the .dll which is the program or my scripting. Has anyone done anything like this with AutoIT and found this problem? Is there anything wrong with my code :/?

Any help is very much appreciated.

CalBoy

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