Jump to content
Sign in to follow this  
JimC

trouble with while loop

Recommended Posts

JimC

I am writing a project which is basically a gui that creates an unattended xp cd. This particular func calls an external exe to integrate the drivers into the source. My problem is the while statement. This is being used until the title of the external executable changes to complete. It seems to work correctly by clicking close on the app, but another button in my gui doesnt do anything unless I remove the while statement. The weird thing is that it closes the external app which seems as if it is working. Any suggestions would be greatly appreciated.

Func Driver_Gui() ; Switch to Driver Gui

GUICtrlSetState($but_driver, $gui_disable)

$drdir = $xpsrce &"\Drivers"

$tempdir="c:\temp\drivers"

if FileExists($drdir &'\slmadrv.txt') Then

$drivedir=$tempdir

EndIf

While $drivedir = ""

$ans = MsgBox(262165, "Warning", "This directory does not contain Sallie Mae prepared drivers")

If $ans = 2 Then Return

Sleep(2000)

WEnd

$message = GUICtrlCreateLabel('Copying drivers to the local directory for integration', 10, 405, 400, 20)

CopyDirWithProgress($drdir,$tempdir)

sleep(5000)

GUICtrlDelete($message)

$message = GUICtrlCreateLabel('Driver have been copied successfully.', 10, 405, 400, 20)

sleep(5000)

GUICtrlDelete($message)

GUICtrlSetState($but_driver, $gui_disable)

$file = @SystemDir &'\drvcomp.ini'

_FileWriteToLine($file, 2, 'Source='&$drivedir &'\',1)

_FileWriteToLine($file, 3 , 'Destination='&$xpcd & '\i386\',1)

;RunWait('Drvcomp.exe', @SystemDir,@SW_HIDE)

run("drvcomp.exe",@SystemDir)

If Not WinActive("[Class:#32770]") Then

Winactivate("[Class:#32770]")

EndIf

ControlClick("[Class:#32770]", "Start", "[ClassNN:Button2]", "left", 1)

While 1

$message = GUICtrlCreateLabel('Drivers are being integrated to ' & $xpcd & '\I386 directory.', 10, 405, 400, 20)

sleep(3000)

GUICtrlDelete($message)

$title=WinGetTitle("","")

If Not WinActive("[Class:#32770]") Then

Winactivate("[Class:#32770]")

EndIf

IF $title = "Driver Compressor Setup: Completed" then ExitLoop

IF Not ProcessExists("drvcomp.exe") Then ExitLoop

WEnd

DriveMapDel($xpsrce); unmaps the drive which was mapped to the dfs pointing to xpsource

If Not WinActive("[Class:#32770]") Then

Winactivate("[Class:#32770]")

EndIf

ControlClick("[Class:#32770]", "Close", "[ClassNN:Button2]", "left", 1)

$message = GUICtrlCreateLabel('Drivers have been integrated to working directory', 10, 405, 400, 20)

Sleep(5000)

GUICtrlDelete($message)

DirRemove("c:\temp\Drivers",1)

GUICtrlSetState($but_osbuild, $gui_enable)

EndFunc ;==>Driver_Gui

Share this post


Link to post
Share on other sites
Zedna

Lokk at my comments inside ...

Func Driver_Gui() ; Switch to Driver Gui
    GUICtrlSetState($but_driver, $gui_disable)
    $drdir = $xpsrce & "\Drivers"
    $tempdir = "c:\temp\drivers"
    If FileExists($drdir & '\slmadrv.txt') Then
        $drivedir = $tempdir
    EndIf
    While $drivedir = ""
        $ans = MsgBox(262165, "Warning", "This directory does not contain Sallie Mae prepared drivers")
        If $ans = 2 Then Return
        Sleep(2000)
    WEnd
    $message = GUICtrlCreateLabel('Copying drivers to the local directory for integration', 10, 405, 400, 20)
    CopyDirWithProgress($drdir, $tempdir)
    Sleep(5000)
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('Driver have been copied successfully.', 10, 405, 400, 20)
    Sleep(5000)
    GUICtrlDelete($message)
    GUICtrlSetState($but_driver, $gui_disable)
    $file = @SystemDir & '\drvcomp.ini'
    _FileWriteToLine($file, 2, 'Source=' & $drivedir & '\', 1)
    _FileWriteToLine($file, 3, 'Destination=' & $xpcd & '\i386\', 1)
    ;RunWait('Drvcomp.exe', @SystemDir,@SW_HIDE)
    Run("drvcomp.exe", @SystemDir)
    If Not WinActive("[Class:#32770]") Then
        WinActivate("[Class:#32770]")
    EndIf
    ControlClick("[Class:#32770]", "Start", "[ClassNN:Button2]", "left", 1)
    While 1
        ; ### Zedna ###
        $msg = GuiGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $your_button1
                ; your action for that button1
            Case $msg = $your_button2
                ; your action for that button2
        EndSelect
        ; ### end
        $message = GUICtrlCreateLabel('Drivers are being integrated to ' & $xpcd & '\I386 directory.', 10, 405, 400, 20)
        ; ### Zedna ###
        Sleep(3000) ; --> you must replace this by TimerDiff() logic !!!
        ; ### end
        GUICtrlDelete($message)
        $title = WinGetTitle("", "")
        If Not WinActive("[Class:#32770]") Then
            WinActivate("[Class:#32770]")
        EndIf
        If $title = "Driver Compressor Setup: Completed"  Then ExitLoop
        If Not ProcessExists("drvcomp.exe") Then ExitLoop
    WEnd
    DriveMapDel($xpsrce); unmaps the drive which was mapped to the dfs pointing to xpsource
    If Not WinActive("[Class:#32770]") Then
        WinActivate("[Class:#32770]")
    EndIf
    ControlClick("[Class:#32770]", "Close", "[ClassNN:Button2]", "left", 1)

    $message = GUICtrlCreateLabel('Drivers have been integrated to working directory', 10, 405, 400, 20)
    Sleep(5000)
    GUICtrlDelete($message)
    DirRemove("c:\temp\Drivers", 1)
    GUICtrlSetState($but_osbuild, $gui_enable)

EndFunc   ;==>Driver_Gui

Share this post


Link to post
Share on other sites
JimC

Still confused. my next function called osbuild will not work unless I comment out the while loop in the Driver_gui function. The weird thing is that I get the msgbox that I places there as a test to make sure I get out of the while loop. The next button is turned on as requsted by the code. Howeve when I click the next button nothing happens. I comment out the while loop, leave the code after the while loop. That is code is executed and the next button is activated. I click the

osbuild button and it performs the function assigned to it. Thanks in advance for any help....

#Region converted Directives from C:\Documents and Settings\lpjmc0\Desktop\XPGUI\SLMA Unattended.au3.ini
#AutoIt3Wrapper_aut2exe=C:\Program Files\AutoIt3\Aut2Exe\Aut2Exe.exe
#AutoIt3Wrapper_outfile=G:\XPGUI\SLMA Unattended.exe
#AutoIt3Wrapper_Res_Comment=http://www.hiddensoft.com/autoit3/compiled.html
#AutoIt3Wrapper_Res_Description=AutoIt v3 Compiled Script
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=n
#AutoIt3Wrapper_Run_AU3Check=4
#EndRegion converted Directives from C:\Documents and Settings\lpjmc0\Desktop\XPGUI\SLMA Unattended.au3.ini
#NoTrayIcon
#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=MainIcon.ico
#AutoIt3Wrapper_outfile=SLAP.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=SlipStreams, removes useless folders, creates simple Winnt.sif, Dotnetfx folder, Software folder, $OEM$ directory structure, Cmdline.txt, RunOnceEX.cmd, OobeInfo.ini, Regtweaks.reg, Prepare.cmd and Cleanup.cmd.
#AutoIt3Wrapper_Res_Description=WinXP Unattended CD Autoit3 SlipStreamer.
#AutoIt3Wrapper_Res_Fileversion=1.0.0.1
#AutoIt3Wrapper_Res_LegalCopyright=MHz
#AutoIt3Wrapper_Res_Field=Platform|NT
#AutoIt3Wrapper_Res_Field=Autoit version|3.2.4.9
#AutoIt3Wrapper_Run_After=Del "%scriptdir%\WinXP Unattended CD AutoIt3 SlipStreamer_Obfuscated.au3" > Nul
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/cs=0 /cn=0 /cf=0 /cv=0 /sf=1
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#Region - AutoIt3Wrapper Directives
#EndRegion - AutoIt3Wrapper Directives

; Script Name:  WinXP Unattended CD SlipStreamer.
; July 2007. Updated to 3.2.4.9 syntax.

#Region - Variables



#Region - - Common
Global $title = 'Windows XP Unattended CD SlipStreamer'; Window Title.
Global $xpsrce; This is wher ethe source resides on slma dfs
Global $message; Displayed Messages in Status bar.
Global $xpcd; HDD Destination.
Global $hfdir;Hotfix directory
Global $gui_000; Main Gui
Global $gui_100; Extra Options Gui
Global $file, $text, $lines, $aFile
Global $line_01, $line_02, $line_03, $line_04, $line_05, $line_06, $line_07
Global $ans, $spack, $tz_result, $aFile, $hfdir, $ImageBuild
Global $xres, $yres, $but_iso_start, $but_iso_write, $location, $targetfile, $drivedir, $save, $xpsrce, $drvumap, $xpcd, $tempdir
#EndRegion
#EndRegion

#Region - FileInstallation Tools\*.*
FileInstall('Tools\CDImage.exe', @SystemDir & '\')
FileInstall('Tools\qchain.exe', @SystemDir & '\')
FileInstall('Tools\drvcomp.exe', @SystemDir & '\')
FileInstall('Tools\drvcomp.ini', @SystemDir & '\',1)
FileInstall('Tools\7za.exe', @SystemDir & '\')
FileInstall('Tools\iso-burner.exe', @SystemDir & '\')
FileInstall('Tools\7z.exe', @SystemDir &'\')
DirCreate(@AppDataDir & '\' & $title & '\')
FileInstall('Tools\HelpGuide.hlp', @AppDataDir & '\' & $title & '\')
#EndRegion


#include <GUIConstants.au3>
#include <array.au3>
#include <file.au3>
#include <process.au3>
#include <CopyWithCustomProgress.au3>
#include <String.au3>
#include <date.au3>
#Region - Menu
Global $aut2exe = RegRead('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\Aut2Exe.exe', '')
Global $filemenu1 = GUICtrlCreateMenu("&File")
Global $exititem = GUICtrlCreateMenuItem("Exit", $filemenu1)
Global $filemenu2 = GUICtrlCreateMenu("&Save")
Global $savesingle = GUICtrlCreateMenu("Save", $filemenu2, 1)
Global $saveitem1 = GUICtrlCreateMenuItem("Winnt.sif", $savesingle)
Global $saveitem2 = GUICtrlCreateMenuItem("Cmdlines.txt", $savesingle)
Global $saveitem3 = GUICtrlCreateMenuItem("RunOnceEX.au3", $savesingle)
Global $saveitem4 = GUICtrlCreateMenuItem("Oobeinfo.ini", $savesingle)
Global $saveitem5 = GUICtrlCreateMenuItem("RegTweaks.reg", $savesingle)
Global $saveitem6 = GUICtrlCreateMenuItem("Prepare.au3", $savesingle)
Global $saveitem7 = GUICtrlCreateMenuItem("Cleanup.au3", $savesingle)
Global $saveitem8 = GUICtrlCreateMenuItem("Startup.au3", $savesingle)
Global $saveitem9 = GUICtrlCreateMenuItem("Autorun.inf", $savesingle)
Global $saveitemall = GUICtrlCreateMenuItem("Save All", $filemenu2)
If $aut2exe <> '' Then
    Global $filemenu3 = GUICtrlCreateMenu("&Compile")
    Global $compileitem1 = GUICtrlCreateMenuItem("RunOnceEX.au3", $filemenu3)
    Global $compileitem2 = GUICtrlCreateMenuItem("Prepare.au3", $filemenu3)
    Global $compileitem3 = GUICtrlCreateMenuItem("Cleanup.au3", $filemenu3)
    Global $compileitem4 = GUICtrlCreateMenuItem("Startup.au3", $filemenu3)
EndIf
#EndRegion




; GUI Main
#Region - Gui - Main Create
$gui_000 = GUICreate($title, 600, 458, -1, -1, 0x00020000)
Global $Button_Help = GUICtrlCreateButton('Help', 550, 2, 40, 22)
GUICtrlSetFont(-1, 8)
GUICtrlSetTip(-1, 'F1')
GUISetFont(9, 300)
GUICtrlCreateTab(3, 4, 590, 400)
#endregion

#Region - Tab - Introduction           ( 100 - 102 )
GUICtrlCreateTabItem(" Introduction ")
GUICtrlSetState(-1, $gui_show)
GUICtrlCreateLabel('Simply press F1 for Help Guide.' & @CRLF _
         & 'This program will facilitate the creation of the official XP unattended intall.' & @CRLF _
         & 'Space Saving Tips will remove folders which are useless for unattended cd. ' & @CRLF _
         & "It will allow you to integrate SP3 when available as well as integrate post SP2 MS hotfixes." & @CRLF _
         & 'It will then allow you to integrate drivers for our standard PCs configurations' & @CRLF & @CRLF _
         & 'It will copy the $OEM$ directory to your source' & @CRLF & 'Lastly it will create the iso and also burn it to cd.' & @CRLF & @CRLF _
         & 'Good Luck !' & @CRLF & @CRLF & 'JC', 30, 60, 535, 250)
GUICtrlCreateLabel('AutoIT ' & @AutoItVersion, 30, 380, -1, 15)
GUICtrlSetFont(-1, 7)
Global $bye = GUICtrlCreateButton('Exit', 490, 350, 82)
#EndRegion
#Region - Tab - Slipstream           ( 200 - 211 )
GUICtrlCreateTabItem(" Copy and Integrate"); New Tab
GUICtrlCreateGroup(' Space Saving Tips ', 20, 40, 195, 340)
GUICtrlCreateLabel(" Remove useless folders so you will have more room on your cd for more software.", 35, 55, 160, 50)
GUICtrlSetTip(-1, 'More inforation at [url="http://unattended.msfn.org/xp/space_saving_tips.htm')"]http://unattended.msfn.org/xp/space_saving_tips.htm')[/url]
Global $chk_200 = GUICtrlCreateCheckbox("DotNetFx", 40, 100)
GUICtrlSetTip(-1, 'If you dont need dotnet leave it checked.')
GUICtrlSetState(-1, $gui_checked)
Global $chk_201 = GUICtrlCreateCheckbox("Cmpnents", 40, 130)
GUICtrlSetTip(-1, 'If you have tabletpc or media edition, you may want to leave it unchecked.')
GUICtrlSetState(-1, $gui_checked)
Global $chk_202 = GUICtrlCreateCheckbox("Docs", 40, 160)
GUICtrlSetTip(-1, 'Stores a logo in it. Can be safely removed.')
GUICtrlSetState(-1, $gui_checked)
Global $chk_203 = GUICtrlCreateCheckbox("Support", 40, 190)
GUICtrlSetTip(-1, 'Stores Support tools. Can be safely removed.')
GUICtrlSetState(-1, $gui_checked)
Global $chk_205 = GUICtrlCreateCheckbox("ValueAdd", 40, 220)
GUICtrlSetTip(-1, 'Stores Netbeui, Cytrix and other addons. Can be safely removed.')
GUICtrlSetState(-1, $gui_checked)
Global $chk_206 = GUICtrlCreateCheckbox("I386 \ Lang", 40, 250)
GUICtrlSetTip(-1, 'Extra languge support other then the language of your Windows CD.')
GUICtrlSetState(-1, $gui_checked)
Global $chk_207 = GUICtrlCreateCheckbox("I386 \ Win9xMig", 40, 280)
GUICtrlSetTip(-1, 'Stores files for migrating from 9x systems to XP. Can be safely removed.')
GUICtrlSetState(-1, $gui_checked)
Global $chk_208 = GUICtrlCreateCheckbox("I386 \ Win9xUpg", 40, 310)
GUICtrlSetTip(-1, 'Stores files for upgrading from 9x systems to XP. Can be safely removed.')
GUICtrlSetState(-1, $gui_checked)
Global $chk_209 = GUICtrlCreateCheckbox("I386 \ WinntUpg", 40, 340)
GUICtrlSetTip(-1, 'Stores files for upgrading from earlier NT systems to XP. Can be safely removed.')
GUICtrlSetState(-1, $gui_checked)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group
GUICtrlCreateGroup('Copy XP Source CD. ', 235, 40, 340, 110)
Global $but_xp_copy = GUICtrlCreateButton('Start Copy of Windows XP SP2 CD', 330, 80)
GUICtrlSetTip(-1, 'Starts the copying of source as well as triming for space savings. ')
GUICtrlCreateGroup('Service Pack Integration', 235, 160, 340, 110)
Global $but_sp_browse = GUICtrlCreateButton('Browse for Service Pack 3', 330, 180)
GUICtrlSetTip(-1, 'Wait for Service Pack 3 before using.')
GUICtrlSetState($but_sp_browse, $gui_disable)
GUICtrlCreateGroup('Hot Fix Integration ', 235, 270, 340, 110)
;Global $but_hf_browse = GUICtrlCreateButton('Browse for HotFix directory', 330, 290)
GUICtrlSetTip(-1, 'Sets the directory from which you will integrate hotfixes.')
;GUICtrlSetState($but_hf_browse, $gui_disable)
Global $but_hot_intergrate = GUICtrlCreateButton('Start Integration', 330, 320)
GUICtrlSetTip(-1, 'This will start the integration of SP3 and then hotfixes.')
GUICtrlSetState($but_hot_intergrate, $gui_disable)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group
#EndRegion

#Region - Tab - Post Tools           ( ' ' - ' ' )
Global $volname, $but_driver
Global $but_iso_start
If Not FileExists(@AppDataDir & '\' & $title & '\Settings.ini') Then
    GUICtrlSetState($but_driver, $gui_disable)
EndIf
GUICtrlCreateTabItem(" Drivers/OEM/ISO ")

GUICtrlCreateGroup("", -99, -99, 1, 1);close group
GUICtrlCreateGroup('Driver Integrator', 20, 155, 280, 110)
GUICtrlCreateLabel(' This section will be used to integrate drivers into your build. ', 40, 180, 170, 50)
Global $but_driver = GUICtrlCreateButton('   DrvComp   ', 220, 210)
GUICtrlSetTip(-1, 'Runs external program called Drvcomp which integrates drivers')
GUICtrlCreateGroup("", -99, -99, 1, 1);close group
GUICtrlSetState($but_driver, $gui_disable)
GUICtrlCreateGroup('OEM decompress- Non boot server', 20, 40, 280, 110)
Global $but_expand = GUICtrlCreateButton(' Decompress ', 210, 100)
GUICtrlCreateLabel(' Decompresses the $OEM$ directory to your source.', 35, 65, 170, 80)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group
GUICtrlSetState($but_expand, $gui_disable)

GUICtrlCreateGroup('OS Build Creation', 20, 270, 280, 110)
Global $but_osbuild = GUICtrlCreateButton(' OS-Build ', 230, 330)
GUICtrlCreateLabel(' This creates an OS build directory; a compilation of changes to the OS source.', 35, 305, 170, 50)
GUICtrlSetTip(-1, 'This is a snapshot of changes made to the standard XP cd to the current build')
GUICtrlCreateGroup("", -99, -99, 1, 1);close group
GUICtrlSetState($but_osbuild, $gui_disable)
GUICtrlCreateGroup('Write the iso file you created for your project.', 315, 40, 260, 100)
GUICtrlCreateLabel(' To write the iso file press "Write ISO".  ' _
                   & 'Please remove XP source and replace with blank cd.', 335, 65, 150, 65)
Global $but_iso_write = GUICtrlCreateButton('  Write ISO   ', 498, 100)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group
GUICtrlSetState($but_iso_write, $gui_disable)
GUICtrlCreateGroup('Bootable ISO Creator', 315, 146, 260, 234)
GUICtrlCreateLabel(' Just type in a Build and click Create ISO. ' _
         & 'Your iso file will be dropped at the root of your c:\ drive.  ' _
         & 'Please use the format "XPSP02-xxx". ' _
         & 'A progress bar will indicate how far along the file creation has come.', 335, 171, 220, 95)
GUICtrlCreateLabel('Build', 360, 320)
GUICtrlSetTip(-1, 'This will be your CD title')
$volname=GUICtrlCreateInput("XPSP02-XXX", 360, 340, 85,$ES_LEFT,$GUI_SS_DEFAULT_INPUT)
GUICtrlSetState($volname, $gui_disable)
GUICtrlSetLimit($volname, 10)
$but_iso_start = GUICtrlCreateButton('Create ISO', 495, 340)
GUICtrlSetState(-1, $gui_disable)
GUICtrlSetTip(-1, 'Make sure you have a title' & @CRLF & 'Then press to start')
#EndRegion

#Region - - - - CD Check Message       ( ' ' - ' ' )
Global $cddrive
If $cddrive = '' Then
    $message = GUICtrlCreateLabel('No Windows XP CD Detected !', 10, 405, 570, 20)
    Sleep(1500)
    GUICtrlDelete($message)
EndIf
#EndRegion

GUISetState(@SW_SHOW)

#region - Gui Loop
While 1
    Switch GUIGetMsg()
        Case $bye
            DriveMapDel($xpsrce); unmaps the drive which was mapped to the dfs pointing to xpsource
            DirRemove($xpcd, 1);empties the destination directory
            Exit
        Case WinActive($title) = 0; Hotkeys Active
            HotKeySet('{F1}', 'Help')
        Case WinActive($title); Hotkeys Not Active
            HotKeySet('{F1}')
        Case $Button_Help; Help Button
            Help()
        Case $but_driver; Editor button on Post Tools tab
            Driver_Gui()
        Case $gui_event_close; Close to Main Gui
            Main_Gui()
        Case $but_xp_copy; Start copy of XP CD Process
            Start()
;Case $but_hf_browse; Hotfix location
;   FindHotfixes()
        Case $but_hot_intergrate; Hotfix Intergrator
            Hotfixes()
        Case $but_expand; Expand a compressed file
            Expand()
        Case $but_osbuild;
            Osbuild()
        Case $but_iso_start; Create ISO file
            ISO()
        Case $but_iso_write; Write ISO file
            Burn()
        Case $exititem; Gui Exit
            Finish()
        Case $but_sp_browse; Browse for Service Pack
            FindServicePack()
    EndSwitch
WEnd
#endregion

; Gui Switching and Shutdown functions

Func Main_Gui(); Switch to Main Gui
    GUISwitch($gui_100)
    GUISetState(@SW_HIDE)
    Sleep(500)
    GUISwitch($gui_000)
    GUISetState(@SW_SHOW)
EndFunc ;==>Main_Gui

Func Components_Gui(); Switch to Components Gui
    GUISetState(@SW_HIDE)
    Sleep(500)
    GUISwitch($gui_100)
    GUISetState(@SW_SHOW)
    $message = GUICtrlCreateLabel('Defaults are checked at initial start.', 10, 447, 400, 20)
    Sleep(2000)
    GUICtrlDelete($message)
EndFunc ;==>Components_Gui

Func Finish(); Close to Main Gui
        Main_Gui()
EndFunc ;==>Finish

; Hotkey functions

Func Help()
    Run(@ComSpec & ' /c start ' & FileGetShortName(@AppDataDir & '\' & $title) & '\HelpGuide.hlp', '', @SW_HIDE)
EndFunc ;==>Help

; Main Gui functions

Func Start(); Start entire Copy WinXP and Slipstream etc process


    #Region - Choose destination drive

    Dim $xpcd; HDD Destination
    DirRemove("c:\temp\Drivers",1)
    GUICtrlDelete($message)
    $xpcd = FileSelectFolder('Choose Destination Folder', @HomeDrive, 1)
    If $xpcd = '' Then Return
    $message = GUICtrlCreateLabel('Destination Folder is ' & $xpcd, 10, 405, 570, 20)
    DirRemove($xpcd,1)
    DirRemove($xpcd &'\$OEM$',1)
    GUICtrlSetState($but_xp_copy, $gui_disable)
    GUICtrlSetState($chk_200, $gui_disable);disables the checkboxes
    GUICtrlSetState($chk_201, $gui_disable)
    GUICtrlSetState($chk_202, $gui_disable)
    GUICtrlSetState($chk_203, $gui_disable)
    GUICtrlSetState($chk_205, $gui_disable)
    GUICtrlSetState($chk_206, $gui_disable)
    GUICtrlSetState($chk_207, $gui_disable)
    GUICtrlSetState($chk_208, $gui_disable)
    GUICtrlSetState($chk_209, $gui_disable)
    Sleep(2000)
    GUICtrlDelete($message)
    #EndRegion


    #Region - Check for Windows CD.

    Sleep(500)
    FindCD()
    While $cddrive = ""
        $ans = MsgBox(262165, "Warning", "You must not have access to the XP source")
        If $ans = 2 Then Return
        Sleep(2000)
        FindCD()
    WEnd
    #EndRegion

    #Region - Start functions and progress bar for SlipStream.

    GUISetState(@SW_DISABLE)

    Sleep(1000)
    CopyDirWithProgress($cddrive, $xpcd)
    Removal()
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('Copy and cleanup complete', 10, 405, 400, 20)
    Sleep(5000)
    GUICtrlDelete($message)
    #EndRegion

    GUISetState(@SW_ENABLE)
;GUICtrlSetState($but_hf_browse, $gui_enable)
    GUICtrlSetState($but_hot_intergrate, $gui_enable)
EndFunc ;==>Start

Func FindCD(); Check if Win XP CD in CDRom
;Local $xpsrce, $i
;$drvs = DriveGetDrive("CDROM")
    $xpsrce = DriveMapAdd("*", "\\usagnt\slmadfs\SDO\XP_Source", 8)
    If Not @error Then
;For $i = 1 To $drvs[0]
    ;If DriveStatus($drvs[$i] & "\") = "READY" Then
        ;If FileExists($drvs[$i] & "\WIN51IP.SP2") Then
            ;$cddrive = $drvs[$i]
                If FileExists($xpsrce & "\Xp_SP2\WIN51IP.SP2") Then
                    $cddrive = $xpsrce & "\Xp_SP2"
                EndIf
    ;EndIf
;Next
    EndIf
EndFunc ;==>FindCD

Func CopyDirWithProgress($sOriginalDir, $sDestDir)
;$sOriginalDir and $sDestDir are quite selfexplanatory...
;This func returns:
; -1 in case of critical error, bad original or destination dir
;  0 if everything went all right
; >0 is the number of file not copied and it makes a log file
;  if in the log appear as error message '0 file copied' it is a bug of some windows' copy command that does not redirect output...
    If StringRight($sOriginalDir, 1) <> '\' Then $sOriginalDir = $sOriginalDir & '\'
    If StringRight($sDestDir, 1) <> '\' Then $sDestDir = $sDestDir & '\'
    If $sOriginalDir = $sDestDir Then Return -1

    ProgressOn('Copying...', 'Making list of files...' & @LF & @LF, '', -1, -1)
    Local $aFileList = _FileSearch($sOriginalDir)
    If $aFileList[0] = 0 Then
        ProgressOff()
        SetError(1)
        Return -1
    EndIf

    If FileExists($sDestDir) Then
        If Not StringInStr(FileGetAttrib($sDestDir), 'd') Then
            ProgressOff()
            SetError(2)
            Return -1
        EndIf
    Else
        DirCreate($sDestDir)
        If Not FileExists($sDestDir) Then
            ProgressOff()
            SetError(2)
            Return -1
        EndIf
    EndIf

    Local $iDirSize, $iCopiedSize = 0, $fProgress = 0
    Local $c, $FileName, $iOutPut = 0, $sLost = '', $sError
    Local $Sl = StringLen($sOriginalDir)

    _Quick_Sort($aFileList, 1, $aFileList[0])

    $iDirSize = Int(DirGetSize($sOriginalDir) / 1024)

    ProgressSet(Int($fProgress * 100), $aFileList[$c], 'Coping file:')
    For $c = 1 To $aFileList[0]
        $FileName = StringTrimLeft($aFileList[$c], $Sl)
        ProgressSet(Int($fProgress * 100), $aFileList[$c] & ' -> ' & $sDestDir & $FileName & @LF & 'Total KiB: ' & $iDirSize & @LF & 'Done KiB: ' & $iCopiedSize, 'Coping file:  ' & Round($fProgress * 100, 2) & ' %   ' & $c & '/' & $aFileList[0])

        If StringInStr(FileGetAttrib($aFileList[$c]), 'd') Then
            DirCreate($sDestDir & $FileName)
        Else
            If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then
                If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then;Tries a second time
                    If RunWait(@ComSpec & ' /c copy /y "' & $aFileList[$c] & '" "' & $sDestDir & $FileName & '">' & @TempDir & '\o.tmp', '', @SW_HIDE) = 1 Then;and a third time, but this time it takes the error message
                        $sError = FileReadLine(@TempDir & '\o.tmp', 1)
                        $iOutPut = $iOutPut + 1
                        $sLost = $sLost & $aFileList[$c] & '  ' & $sError & @CRLF
                    EndIf
                    FileDelete(@TempDir & '\o.tmp')
                EndIf
            EndIf

            FileSetAttrib($sDestDir & $FileName, "+A-RSH");<- Comment this line if you do not want attribs reset.

            $iCopiedSize = $iCopiedSize + Int(FileGetSize($aFileList[$c]) / 1024)
            $fProgress = $iCopiedSize / $iDirSize
        EndIf
    Next

    ProgressOff()

    If $sLost <> '' Then;tries to write the log somewhere.
        If FileWrite($sDestDir & 'notcopied.txt', $sLost) = 0 Then
            If FileWrite($sOriginalDir & 'notcopied.txt', $sLost) = 0 Then
                FileWrite(@WorkingDir & '\notcopied.txt', $sLost)
            EndIf
        EndIf
    EndIf

    Return $iOutPut
EndFunc ;==>CopyDirWithProgress

Func _FileSearch($sIstr, $bSF = 1)
; $bSF = 1 means looking in subfolders
; $sSF = 0 means looking only in the current folder.
; An array is returned with the full path of all files found. The pos [0] keeps the number of elements.
    Local $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1]
    $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1))
    If $sCP = '' Then $sCP = @WorkingDir & '\'
    $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1))
    If $sCriteria = '' Then $sCriteria = '*.*'

;To begin we seek in the starting path.
    $sCS = FileFindFirstFile($sCP & $sCriteria)
    If $sCS <> -1 Then
        Do
            $sCF = FileFindNextFile($sCS)
            If @error Then
                FileClose($sCS)
                ExitLoop
            EndIf
            If $sCF = '.' Or $sCF = '..' Then ContinueLoop
            $sOutPut = $sOutPut & $sCP & $sCF & @LF
        Until 0
    EndIf

;And after, if needed, in the rest of the folders.
    If $bSF = 1 Then
        $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *.
        Do
            $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1), 1);current search.
            $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path.
            $iH = FileFindFirstFile($sCS)
            If $iH <> -1 Then
                Do
                    $sCF = FileFindNextFile($iH)
                    If @error Then
                        FileClose($iH)
                        ExitLoop
                    EndIf
                    If $sCF = '.' Or $sCF = '..' Then ContinueLoop
                    If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then
                        $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer;Every folder found is added in the begin of buffer
                        $sFP = $sCP & $sCF & '\';                              for future searches
                        $iH2 = FileFindFirstFile($sFP & $sCriteria);         and checked with the criteria.
                        If $iH2 <> -1 Then
                            Do
                                $sCF2 = FileFindNextFile($iH2)
                                If @error Then
                                    FileClose($iH2)
                                    ExitLoop
                                EndIf
                                If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop
                                $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output.
                            Until 0
                        EndIf
                    EndIf
                Until 0
            EndIf
            $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '')
        Until $sBuffer = ''
    EndIf

    If $sOutPut = '' Then
        $aNull[0] = 0
        Return $aNull
    Else
        Return StringSplit(StringTrimRight($sOutPut, 1), @LF)
    EndIf
EndFunc ;==>_FileSearch

Func _Quick_Sort(ByRef $SortArray, $First, $Last);Larry's code
    Dim $Low, $High
    Dim $Temp, $List_Separator

    $Low = $First
    $High = $Last
    $List_Separator = StringLen($SortArray[($First + $Last) / 2])
    Do
        While (StringLen($SortArray[$Low]) < $List_Separator)
            $Low = $Low + 1
        WEnd
        While (StringLen($SortArray[$High]) > $List_Separator)
            $High = $High - 1
        WEnd
        If ($Low <= $High) Then
            $Temp = $SortArray[$Low]
            $SortArray[$Low] = $SortArray[$High]
            $SortArray[$High] = $Temp
            $Low = $Low + 1
            $High = $High - 1
        EndIf
    Until $Low > $High
    If ($First < $High) Then _Quick_Sort($SortArray, $First, $High)
    If ($Low < $Last) Then _Quick_Sort($SortArray, $Low, $Last)
    EndFunc ;==>_Quick_Sort

Func Removal(); Remove space saving folders after Slipstream
    If GUICtrlRead($chk_200) = $gui_checked Then
        DirRemove($xpcd & '\DotNetFx', 1)
        $message = GUICtrlCreateLabel('Removing DotNetFx folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf
    If GUICtrlRead($chk_201) = $gui_checked Then
        DirRemove($xpcd & '\cmpnents', 1)
        $message = GUICtrlCreateLabel('Removing Cmpnents folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf
    If GUICtrlRead($chk_202) = $gui_checked Then
        DirRemove($xpcd & '\docs', 1)
        $message = GUICtrlCreateLabel('Removing Docs folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf
    If GUICtrlRead($chk_203) = $gui_checked Then
        DirRemove($xpcd & '\support', 1)
        $message = GUICtrlCreateLabel('Removing Support folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf
    If GUICtrlRead($chk_205) = $gui_checked Then
        DirRemove($xpcd & '\valueadd', 1)
        $message = GUICtrlCreateLabel('Removing ValueAdd folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf
    If GUICtrlRead($chk_206) = $gui_checked Then
        DirRemove($xpcd & '\i386\lang', 1)
        $message = GUICtrlCreateLabel('Removing Lang folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf
    If GUICtrlRead($chk_207) = $gui_checked Then
        DirRemove($xpcd & '\i386\win9xmig', 1)
        $message = GUICtrlCreateLabel('Removing Win9xMig folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf
    If GUICtrlRead($chk_208) = $gui_checked Then
        DirRemove($xpcd & '\i386\win9xupg', 1)
        $message = GUICtrlCreateLabel('Removing Win9xUpg folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf
    If GUICtrlRead($chk_209) = $gui_checked Then
        DirRemove($xpcd & '\i386\winntupg', 1)
        $message = GUICtrlCreateLabel('Removing WinntUpg folder', 10, 405, 400, 20)
        Sleep(500)
        GUICtrlDelete($message)
    EndIf



EndFunc ;==>Removal

Func FindServicePack(); Locate Service Pack
    GUICtrlDelete($message)
    $location = IniRead(@AppDataDir & '\' & $title & '\Settings.ini', 'Location', 'Service Pack', @HomeDrive)
    $message = GUICtrlCreateLabel('Redistributable file or if already extracted, Update.exe', 10, 405, 590, 20)
    $spack = FileOpenDialog('Choose Service Pack file', $location, 'exe (*.exe)')
    GUICtrlDelete($message)
    If $spack = 1 Then
        $spack = ''
    Else
        $message = GUICtrlCreateLabel('Service Pack file is ' & $spack, 10, 405, 590, 20)
    EndIf
    Sleep(3000)
    GUICtrlDelete($message)
EndFunc ;==>FindServicePack

Func SlipStream(); Slipstream Service Pack into Win XP
    Local $err
    If $spack <> '' Then
        $message = GUICtrlCreateLabel('Service Pack Slipstream In Progress', 10, 405, 400, 20)
        Run($spack & ' /integrate:' & $xpcd)
        $err = WinWaitActive('Service Pack 2 Setup', 'Integrated install has completed', 120)
        If $err = 1 Then Send('{ENTER}')
        DirCreate(@AppDataDir & '\' & $title)
        IniWrite(@AppDataDir & '\' & $title & '\Settings.ini', 'Location', 'Service Pack', $spack)
    EndIf

EndFunc ;==>SlipStream

Func FindHotfixes(); Locate Hotfixes directory
    #Region - Choose location of hotfixes
    Dim $hfdir;  location of hotfixes.
;$hfdir = FileSelectFolder('Choose location of hotfixes to Integrate', @HomeDrive)
    $hfdir = $xpsrce &"\Hotfixes"
    If $hfdir = '' Then Return
    $message = GUICtrlCreateLabel('Hotfix location is ' & $hfdir, 10, 405, 570, 20)
    Sleep(2000)
    GUICtrlDelete($message)
;GUICtrlSetState($but_hf_browse, $gui_enable)
    #EndRegion
EndFunc ;==>FindHotfixes

Func Hotfixes(); Slipstream Hotfixes into Win XP
    $svcpackc = $xpcd & 'i386\svcpack.in_'
    $svcpack = $xpcd & '\i386\svcpack.inf'
    $svcdir = $xpcd & "\I386\svcpack"
    FindHotfixes()
;GUICtrlSetState($but_hf_browse, $gui_disable)
    GUICtrlSetState($but_hot_intergrate, $gui_disable); Start Button
    FileDelete($svcpackc); this is necessary to ensure that the svcpack.inf is used
    $arr1 = _FileListToArray($hfdir)
    _ArraySort($arr1, 1)
    DirCreate($svcdir)
    For $c = 0 To _ArrayMaxIndex($arr1) - 1; counter for array
        $d = _ArrayMaxIndex($arr1) - 1; temp holder for max amount of items held in array
        $e = $d - $c;this handles the count of the number of hotfixes left to integrate
        Local $fileinfo[14]
        Local $vstring[14] = ['FileVersion', 'FileDescription', 'LegalCopyright', 'Comments', 'InternalName', _
                'ProductName', 'CompanyName', 'ProductVersion', 'LegalTrademarks', 'PrivateBuild', 'OriginalFilename', 'SpecialBuild', _
                'Installer Engine']
        $hotfix = ($hfdir & "\" & $arr1[$c])
        For $i = 0 To UBound($fileinfo) - 1
            $fileinfo[$i] = FileGetVersion($hotfix, $vstring[$i])
        Next
;_ArrayDisplay($fileinfo)
        If $fileinfo[12] = "update.exe" Then
            $message = GUICtrlCreateLabel('Integrating: ' & $arr1[$c], 10, 405, 500, 20)
            $message1 = GUICtrlCreateLabel($e & ' remaining hotfixes.', 400, 405, 500, 20)
            $sExtCmd = $hfdir & "\" & $arr1[$c] & ' /integrate:' & $xpcd & ' /passive /norestart'
            ConsoleWrite("Debug: $sExtCmd = " & $sExtCmd & @LF)
            $prevcount = DirGetSize($svcdir, 1)
            $RET = RunWait($sExtCmd, $hfdir)
            $postcount = DirGetSize($svcdir, 1)
            If $prevcount[1] = $postcount[1] Then; This handles non standard hotfixes that dont integrate.  It copies the 8.3 formatted exe to the svcpack directory and add entry in svcpack.inf
                $caphotfix = StringUpper($arr1[$c])
                $search = StringRegExp($caphotfix, '(KB\d\d\d\d\d\d)', 1)
                $Temp = $search[0] & "a.exe"
                $copy = FileCopy($hfdir & "\" & $arr1[$c], $svcdir & "\" & $Temp, 8)
                $linecount = 11
                _FileWriteToLine($svcpack, $linecount, $Temp & " /q /n /z")
            EndIf
        ElseIf $fileinfo[12] = "msiexec.exe" Then; this was added to accomidate kb927978  9-11-07
            $message = GUICtrlCreateLabel('Integrating: ' & $arr1[$c], 10, 405, 500, 20)
            $message1 = GUICtrlCreateLabel($e & ' remaining hotfixes.', 400, 405, 500, 20)
            $caphotfix = StringUpper($arr1[$c])
            $search = StringRegExp($caphotfix, '(KB\d\d\d\d\d\d)', 1)
            $Temp = $search[0] & ".exe"
            $copy = FileCopy($hfdir & "\" & $arr1[$c], $svcdir & "\" & $Temp, 8)
            $linecount = 11
            _FileWriteToLine($svcpack, $linecount, $Temp & " /qn /norestart ")
        Else
            $message = GUICtrlCreateLabel('Integrating: ' & $arr1[$c], 10, 405, 500, 20)
            $message1 = GUICtrlCreateLabel($e & ' remaining hotfixes.', 400, 405, 500, 20)
            $caphotfix = StringUpper($arr1[$c])
            MsgBox(1, "", $caphotfix)
            $search = StringRegExp($caphotfix, '(KB\d\d\d\d\d\d)', 1)
            $Temp = $search[0] & ".exe"
            $copy = FileCopy($hfdir & "\" & $arr1[$c], $svcdir & "\" & $Temp, 8)
            $linecount = 11
            _FileWriteToLine($svcpack, $linecount, $Temp & " Q:A /R:N ")
        EndIf
        GUICtrlDelete($message)
        GUICtrlDelete($message1)
    Next

    $message = GUICtrlCreateLabel(' Hotfix Integration Complete. ', 10, 405, 570, 20)
    Sleep(5000)
    GUICtrlDelete($message)
    $arr2 = _FileListToArray($svcdir, "*.exe", 1);need to test this more
    $message = GUICtrlCreateLabel('There were ' & UBound($arr1) - 1 & 'hot fixes to install and ' & UBound($arr2) - 1 & 'hotfixes were installed.', 10, 405, 500, 20)
    Sleep(5000)
    GUICtrlDelete($message)
    _ArraySort($arr2)
;The following section is used to make sure the hotfixes are run in the proper order
    Dim $numhotfix
    $numhotfix = UBound($arr2) -1
    local $sort[$numhotfix]
    _FileReadToArray($svcpack,$sort)
    _ArraySort($sort,0,11,$numhotfix+10)
    _FileWriteFromArray($svcpack,$sort)
;need to delete the first line of the svcpack file as it is invalid
    _FileWriteToLine($svcpack,1,"",1)
;This adds the qchain command to svcpack to ensure the newest file is installed from hot fixes
    $linecount = UBound($arr2) + 10
    _FileWriteToLine($svcpack, $linecount, "qchain.exe", 0)
    FileMove(@SystemDir & "\qchain.exe", $svcdir, 1)
    GUICtrlSetState($but_expand, $gui_enable)
    
EndFunc ;==>Hotfixes
Func FindDriverDir()
EndFunc

Func Expand(); Expand the $OEM$ file
    
    GUICtrlSetState($but_expand, $gui_disable)
    $expand= $xpsrce & "\misc\"
    $aFile="$OEM$.7z"
    $ExtractCommand = (@SystemDir & "\7za.exe x  -y -o" & $xpcd & "\$OEM$ " & " " & $expand & $aFile)
    $ExtractPID = RunWait($ExtractCommand, "", @SW_HIDE)
    Sleep(2000)
    $filesif=$xpsrce &"\misc\winnt.sif"
;msgbox(0,"",$filesif)
    FileCopy($filesif, $xpcd & "\I386", 1)
    $message = GUICtrlCreateLabel('$OEM$ directory has been expanded to working directory', 10, 405, 400, 20)
    Sleep(5000)
    GUICtrlDelete($message)
    FileMove(@SystemDir &'\7za.exe',$xpcd &'\$OEM$\')
    FileMove(@SystemDir &'7z.exe',$xpcd &'\$OEM$\')
    GUICtrlSetState($but_driver, $gui_enable)
    
    
EndFunc ;==>Expand
Func Driver_Gui(); Switch to Driver Gui
    GUICtrlSetState($but_driver, $gui_disable)
    $drdir = $xpsrce &"\Drivers"
    $tempdir="c:\temp\drivers"
    if FileExists($drdir &'\slmadrv.txt') Then
     $drivedir=$tempdir
    EndIf
    While $drivedir = ""
        $ans = MsgBox(262165, "Warning", "This directory does not contain Sallie Mae prepared drivers")
        If $ans = 2 Then Return
        Sleep(2000)
    WEnd
    $message = GUICtrlCreateLabel('Copying drivers to the local directory for integration', 10, 405, 400, 20)
    CopyDirWithProgress($drdir,$tempdir)
    sleep(5000)
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('Driver have been copied successfully.', 10, 405, 400, 20)
    sleep(5000)
    GUICtrlDelete($message) 
    GUICtrlSetState($but_driver, $gui_disable)
    $file = @SystemDir &'\drvcomp.ini'
    _FileWriteToLine($file, 2, 'Source='&$drivedir &'\',1)
    _FileWriteToLine($file, 3 , 'Destination='&$xpcd & '\i386\',1)
;RunWait('Drvcomp.exe', @SystemDir,@SW_HIDE)
    run("drvcomp.exe",@SystemDir)
    If Not WinActive("[Class:#32770]") Then
        Winactivate("[Class:#32770]")
    EndIf
    ControlClick("[Class:#32770]", "Start", "[ClassNN:Button2]", "left", 1) 
    While 1 
        $msg= GUIGetMsg()
        $message = GUICtrlCreateLabel('Drivers are being integrated to ' & $xpcd & '\I386 directory.', 10, 405, 400, 20)
        GUICtrlDelete($message)
        $title=WinGetTitle("","")
        If Not WinActive("[Class:#32770]") Then
        Winactivate("[Class:#32770]")
        EndIf
        IF $title = "Driver Compressor Setup: Completed" then ExitLoop 
;IF Not ProcessExists("drvcomp.exe") Then ExitLoop
    WEnd
    msgbox(0,0,"got out of loop")
    DriveMapDel($xpsrce); unmaps the drive which was mapped to the dfs pointing to xpsource
    If Not WinActive("[Class:#32770]") Then
        Winactivate("[Class:#32770]")
    EndIf
    ControlClick("[Class:#32770]", "Close", "[ClassNN:Button2]", "left", 1) 
    
    $message = GUICtrlCreateLabel('Drivers have been integrated to working directory', 10, 405, 400, 20)
    Sleep(5000)
    GUICtrlDelete($message)
    DirRemove("c:\temp\Drivers",1)
    GUICtrlSetState($but_osbuild, $gui_enable)
    
EndFunc ;==>Driver_Gui



Func Osbuild();Builds the OSBuild directory
    Local $linecount1 =1
    dim $arr4, $arr5, $arr6, $arr7, $arr8, $arr9
    GUICtrlSetState($but_osbuild, $gui_disable)
    $message = GUICtrlCreateLabel('The OSbuild Directory is being created.  ', 10, 405, 400, 20)
    FileWriteLine($xpcd &'\$OEM$\postinstall.bat', "%CDDRIVE%\$OEM$\7z.exe e %CDDRIVE%\osbuild.7z -oc:\windows\system32");This is the line that will expand osbuild to installation
    $OSBuild=$xpcd & '\OSBuild'
    DirCreate($OSBuild)
    $OSCustom =$OSBuild &'\OS Custom Files'
    DirCreate($OSCustom)
    DirCopy($xpcd &'\$OEM$', $OSCustom & '\',1)
    $OSCustomI=($OSCustom &'\I386')
    DirCreate($OSCustomI)
    $ImageBuild=($OSBuild &'\ImageBuild.txt')
    _FileCreate($ImageBuild)
    _FileWriteToLine($ImageBuild,$linecount1,"Patches:")
    $linecount1=$linecount1 +1
    $arr3 = _FileListToArray($hfdir)
    _ArraySort($arr3, 1)
    For $t = 0 To _ArrayMaxIndex($arr3) - 1; counter for array
        $dllfiletr = StringTrimRight($arr3[$t],3)
        $dll = $dllfiletr&'dll'
        _FileCreate($xpcd &'\OSBuild\'& $dll)
        _FileWriteToLine($ImageBuild,$linecount1,$dll)
        $linecount1=$linecount1 +1
    Next
    $date = FileGetTime($xpcd &"\I386\WINNT.SIF",0,0)
    $date1=$date[1] & "/" & $date[2] &"/" & $date[0]
    _FileWriteToLine($ImageBuild,$linecount1,"                                                                                   ")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"Create Date of SIF " & $date1)
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"                                                                                   ")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"++++++++++++++++++++++++           WINNT.SIF FOLLOWS:        +++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1   
    If Not _FileReadToArray($xpcd &"\I386\WINNT.SIF",$arr4) Then
        MsgBox(4096,"Error", " Error reading winnt.sif" & @error)
        Exit
    EndIf
    For $u = 1 to UBound($arr4) - 1; counter for array
        _FileWriteToLine($ImageBuild,$linecount1,$arr4[$u])
        $linecount1=$linecount1+1
    Next
    _FileWriteToLine($ImageBuild,$linecount1,"                                                                                   ")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"++++++++++++++++++++++++           cmdlines.txt FOLLOWS:      +++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileReadToArray($xpcd &'\$OEM$\cmdlines.txt',$arr5)
    For $v = 1 to UBound($arr5) - 1; counter for array
        _FileWriteToLine($ImageBuild,$linecount1,$arr5[$v])
        $linecount1=$linecount1+1
    Next
    _FileWriteToLine($ImageBuild,$linecount1,"                                                                                   ")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"++++++++++++++++++++++++           namechng.bat FOLLOWS:      +++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileReadToArray($xpcd &'\$OEM$\namechng.bat',$arr6)
    For $w = 1 to UBound($arr6) - 1; counter for array
        _FileWriteToLine($ImageBuild,$linecount1,$arr6[$w])
        $linecount1=$linecount1+1
    Next
    _FileWriteToLine($ImageBuild,$linecount1,"                                                                                   ")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"++++++++++++++++++++++++           postinstall.bat FOLLOWS:    +++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileReadToArray($xpcd &'\$OEM$\postinstall.bat',$arr7)
    For $x = 1 to UBound($arr7) - 1; counter for array
        _FileWriteToLine($ImageBuild,$linecount1,$arr7[$x])
        $linecount1=$linecount1+1
    Next
    _FileWriteToLine($ImageBuild,$linecount1,"                                                                                   ")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"++++++++++++++++++++++++           HKLM.reg FOLLOWS:          +++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileReadToArray($xpcd &'\$OEM$\HKLM.reg',$arr8)
    For $y = 1 to UBound($arr8) - 1; counter for array
        _FileWriteToLine($ImageBuild,$linecount1,$arr8[$y])
        $linecount1=$linecount1+1
    Next
    _FileWriteToLine($ImageBuild,$linecount1,"                                                                                   ")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"++++++++++++++++++++++++           HKCU.reg FOLLOWS:          +++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileWriteToLine($ImageBuild,$linecount1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
    $linecount1=$linecount1+1
    _FileReadToArray($xpcd &'\$OEM$\HKCU.reg',$arr9)
    For $z = 1 to UBound($arr9) - 1; counter for array
        _FileWriteToLine($ImageBuild,$linecount1,$arr9[$z])
        $linecount1=$linecount1+1
    Next
    GUICtrlDelete($message)
    GUICtrlSetState($volname, $gui_enable)
    GUICtrlSetState($but_iso_start, $gui_enable)
EndFunc;OSBuild
; ISO Creation
Func ISO(); Create ISO file from finished Slipstreamed project
    Local $switches, $wdir, $open, $sourceroot, $targetfile
    Local $bootfile, $vol_label, $open, $upcase, $wdir
    #Region - Prompts
    If GUICtrlRead($volname,1) = '' Then
        $message = GUICtrlCreateLabel('Enter title first !', 10, 405, 570, 20)
        Sleep(3000)
        GUICtrlDelete($message)
        Return
    EndIf
    GUICtrlSetState($but_iso_start, $gui_disable)
    $open = $xpcd
    $message = GUICtrlCreateLabel('Project folder is ' & $open, 10, 405, 570, 20)
    sleep(3000)
    GUICtrlDelete($message)
    $save = "c:\" & GUICtrlRead($volname,1) &'.iso'
;$message = GUICtrlCreateLabel('ISO file is ' & $save, 10, 405, 570, 20)
    #EndRegion
    
    GUISetState(@SW_DISABLE)
    $now=_NowCalcDate()
    $snow=StringTrimLeft($now,2)
    msgbox(0,"",$snow)
    $snow1=StringReplace($snow,"/","")
    msgbox(0."",$snow1)
    $vol1=StringLeft($volname,6)
    msgbox(0,"",$volname)
    msgbox(0,"",$vol1)
    $vol2=StringRight($volname,3)
    msgbox(0,"",$vol2)
    _FileCreate($xpcd &'\OSBuild\'& $vol1&"-"& $now &"-" & $vol2&'.dll')
    _FileWriteToLine($ImageBuild,1, 'Build: '&$vol1& $now & $vol2,0)
;Compresses osbuild directory
    $CompressCommand = (@SystemDir & "\7z.exe a " &$xpcd &"\OSBuild.7z" & $xpcd &"\OSBuild\*")
    RunWait($CompressCommand, "", @SW_HIDE)
    
    #Region - CDImage
    $wdir = @SystemDir
    FileInstall('Tools\boot.img', @SystemDir & '\', 1)
    Sleep(500)
    FileSetAttrib(@SystemDir & '\boot.img', '+H')
    $vol_label = ' -l' & '"'& GUICtrlRead($volname) &'" '
    $bootfile = ' -b' & '"'& @SystemDir & '\boot.img' &'" '
    $switches = ' -h -j1 -x -o -m'
    $sourceroot = ' "' & $open & '" '
    $targetfile = ' "' & $save & '"'
    $message = GUICtrlCreateLabel('Configuring...', 10, 405, 400, 20)
    Sleep(3000)
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('Switches are ' & $switches, 10, 405, 400, 20)
    Sleep(3000)
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('Label is ' & GUICtrlRead($volname), 10, 405, 400, 20)
    Sleep(3000)
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('Boot File is ' & @SystemDir & '\boot.img', 10, 405, 400, 20)
    Sleep(3000)
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('Source folder is ' & $sourceroot, 10, 405, 400, 20)
    Sleep(3000)
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('Target ISO file is ' & $targetfile, 10, 405, 400, 20)
    Sleep(3500)
    GUICtrlDelete($message)
    $message = GUICtrlCreateLabel('ISO Creation In Progress', 10, 405, 150, 20)
    $command = @SystemDir&'\cdimage.exe' & $switches & $vol_label & $bootfile & $sourceroot & $targetfile
    run($command,$wdir,@SW_HIDE)
    While ProcessExists("cdimage.exe")
        ProgressOn("Progress Meter", "ISO Creation Progress", "0 percent")
        For $z=1 to 100
            Sleep (2400)
            ProgressSet($z, $z & '%')
        Next
        ProgressSet(100 , "Done", "Complete")
        sleep(500)
        ProgressOff()
    WEnd
    
;RunWait(@ComSpec & ' /c ' & $wdir & '\cdimage.exe' & $switches & $vol_label & $bootfile & $sourceroot & $targetfile, $wdir, @SW_HIDE)
    $message = GUICtrlCreateLabel('', 10, 405, 400, 20)
    Sleep(1000)
    $message = GUICtrlCreateLabel('ISO Creation Complete', 10, 405, 400, 20)
    
    #EndRegion
    GUISetState(@SW_ENABLE)
    GUICtrlSetState($but_iso_write, $gui_enable)
EndFunc

Func Burn();ISO Burn
    FileDelete(@SystemDir & '\CDImage.exe')
    FileDelete(@SystemDir & '\qchain.exe')
    FileDelete(@SystemDir & '\drvcomp.exe')
    FileDelete(@SystemDir & '\drvcomp.ini')
    FileDelete(@SystemDir & '\winnt.sif')
    FileDelete($xpcd & '\boot.bin')
    msgbox(1,"Please place Blank CD in CD writer", "Please place Blank CD in CD writer")
    GUICtrlSetState($but_iso_write, $gui_disable)
    $command3 = 'iso-burner.exe' &  ' "'& $save &'"'& ' /BURN /EXIT-IF-OK'
    msgbox(1,"",$command3)
    run($command3,@SystemDir)
    $message = GUICtrlCreateLabel('XP CD Creation Complete', 10, 405, 400, 20)
    GUICtrlSetState($but_iso_write, $gui_disable)
EndFunc;ISO Burn
Edited by JimC

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  

×