Jump to content

Catdaddy

Active Members
  • Posts

    33
  • Joined

  • Last visited

About Catdaddy

  • Birthday 09/17/1968

Profile Information

  • Location
    Ohio
  • Interests
    Other than being an amazingly boring, white male American with no website or messenger ID, I work in a mid-size IT department. I play drums to keep my blood pressure low and I enjoy books and movies. I started programming with 8Bit BASIC on a C64. I love retro games and emulation. I found AutoIt back in version 2 days and used it to automate new PC builds and have not looked back since. There's hardly anything I can think of that I can't do in AutoIt. I prefer AutoIt over VB because of the compactness and I don't have to worry about runtimes or framework versions on other peoples PCs. Never wanted to be a full-fledged programmer but I do enjoy making my PC do what I want it to do. AutoIt is supremely perfect for this.

Catdaddy's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. You could try something like this: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> If Not FileExists(@TempDir & "\TrueCrypt Format.exe") Then FileInstall ("C:\Temp\TrueCrypt Format.exe", @TempDir & "\TrueCrypt Format.exe", 1) EndIf If Not FileExists(@TempDir & "\TrueCrypt.exe") Then FileInstall ("C:\Temp\TrueCrypt.exe", @TempDir & "\TrueCrypt.exe", 1) EndIf If Not FileExists(@TempDir & "\TrueCrypt.sys") Then FileInstall ("C:\Temp\TrueCrypt.sys", @TempDir & "\TrueCrypt.sys", 1) EndIf If Not FileExists(@TempDir & "\TrueCrypt-x64.sys") Then FileInstall ("C:\Temp\TrueCrypt-x64.sys", @TempDir & "\TrueCrypt-x64.sys", 1) EndIf ; Confirm volume exists $VolumePath = (@ScriptDir & "\Volume.tc") If Not FileExists ($VolumePath) Then MsgBox(16,"Volume file missing","Could not locate volume file. ") Exit EndIf $Form1 = GUICreate("Authentication", 329, 141, -1, -1) $Input1 = GUICtrlCreateInput("", 32, 56, 265, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL)) GUICtrlSetLimit(-1, 20) $Label1 = GUICtrlCreateLabel("Password:", 32, 32, 53, 17) $Button1 = GUICtrlCreateButton("Cancel", 136, 96, 73, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("OK", 224, 96, 73, 25, $WS_GROUP) GUICtrlSetState ($Button2, $GUI_FOCUS ) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $Password = GUICtrlRead ($Input1) Run(@TempDir & "\truecrypt.exe /q /v " & $VolumePath & " /a /p " & $Password & " /e /b") Exit EndSwitch WEnd Create a volume file in TrueCrypt and name it Volume.tc. Naturally, when you create it you'll also create the password to access it. Copy that file to your USB drive. The size of the file will be dependant on the size of your drive, of course. Take the attached script and place it on your computer under C:\TEMP. Also, copy the following files from a TrueCrypt installation to this folder: TrueCrypt Format.exe TrueCrypt.exe TrueCrypt.sys TrueCrypt-x64.sys When you compile the script from this location it will include these four files in the .exe. Place the compiled script on your USB drive and run it. On a Windows system the script will FileInstall the four TrueCrypt system files to your systems temp folder and run from there. You can experiment with the command line switches in the Run statement; these are just ones I've used with success. This way you don't have to worry about having TrueCrypt installed on any Windows machine you plug the drive into. The TrueCrypt files I use are from version 7.0a and have worked like a charm for me.
  2. Homes32, Great UDF! I'm having trouble with the callback routine to get an accurate progress percentage. When I try and run your sample script I get a variable used before declared error for $Percent. I was hoping maybe you could shed some light on it. Thanks.
  3. This is incredibly cool. I've been using GimageX for a while, and it works great. But this will help me to automate my imaging even more with my own custom scripts. Thank you very much for this UDF.
  4. “PE 3.0 Create Wizard” is a tool I wrote to help build custom PE boot disks and environments. It requires the following to be installed: • Windows 7 (32 or 64 bit) • Microsoft Windows Automated Installation Kit (WAIK)(Latest version) I wrote and tested this on my work laptop which is running the 64 bit version of Windows 7. It's set to only run from Windows 7 but this can be changed easily to any other platform. The reason being is that this script utilizes DISM.EXE which comes natively with Windows 7. You could just as easily add DISM.EXE from the WAIK to your %PATH% and it would work fine. Based on the input and choices you make from the menu the program extracts and constructs the file and folder structure of a PE installation disk from files available in the WAIK. It assumes that the WAIK is installed at the default location on your drive. If it cannot find it it will ask you for the location. Depending on the architecture you choose, it will create a destination folder off the root of your C: drive like so: C:\WinPE_x86 C:\WinPE_ia64 C:\WinPE_amd64 If you already have a folder with any of these names the program will ask permission to overwrite or cancel. Inside each of these folders is a directory named “ISO”. The contents of this folder is what you will burn to disk or copy to a thumb drive. It will also create a small file in the ISO folder of the PE extraction named WINPE. This is a plain text file with an INI format that reflects the user chosen settings that the program used to create that version of PE. Example: [iD] Arch=x86 DriveLetter=P ScratchSpace=128 [Packages] Fonts=0 HTA=1 LegacySetup=0 MDAC=0 PPPoE=0 Scripting=1 Setup=0 SetupClient=0 SetupServer=0 WMI=1 WDS=1 "0" indicates that this package is not installed; "1" means it is. Possibly this file may help anyone trying to build a custom shell or tool inside PE. I don't know, use your imagination. I know the coding is quite elementary and could probably be cleaned up by a more experienced programmer, but I have taken a lot from this site and learned a volume of information about scripting in general from all of the great examples posted here and I just wanted to give something back in return. Have fun. #cs ---------------------------------------------------------------------------- Application Title: PE 3.0 Create Wizard Version: 1.0.2.1 Author: Rick Hager Function: This program will extract a Windows PE installation that can be used for custom boot environments, Windows OS installations, system recovery and diagnostics tools. It works with and requires the installation of the Microsoft WAIK 3.0. It allows you to add custom packages available from the WAIK such as HTA, WMI and additional font support. This version will only run from Windows 7 but can be re-configured to run from other OS versions as well. It assumes the WAIK is installed at the default location. If it cannot find it it will ask the user for the folder location. It can create three different versions of PE by architecture: x86, ia64 and amd64. It will place the resulting files in a folder off the root of C:\. The extraction process mirrors the actions of COPYPE.CMD, the script found inside the WAIK. It uses DISM.EXE to mount the boot.wim file and inject the chosen packages. It will also create a small file in the ISO folder of the PE extraction named WINPE. This is a plain text file with an INI format that reflects the user chosen settings that the program used to create that version of PE. Example: [ID] Arch=x86 DriveLetter=P ScratchSpace=128 [Packages] Fonts=0 HTA=1 LegacySetup=0 MDAC=0 PPPoE=0 Scripting=1 Setup=0 SetupClient=0 SetupServer=0 WMI=1 WDS=1 "0" indicates that this package is not installed; "1" means it is. Possibly this file may help anyone trying to build a custom shell or tool inside PE. This program was built on and tested in Windows 7 64 bit utilizing the MS WAIK and PE 3.0 environments. I cannot guarantee this will work with any earlier versions. #ce ---------------------------------------------------------------------------- #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $WAIKFolder = (@ProgramFilesDir & "\Windows AIK") Global $SourceFolder = ($WAIKFolder & "\Tools\PETools") Global $DestFolder Global $Font Global $HTA Global $LegacySetup Global $MDAC Global $PPPoE Global $Scripting Global $Setup Global $SetupClient Global $SetupServer Global $SRT Global $WMI Global $WDS ;Make sure we're running Windows 7 ;================================= If @OSVersion <> "Win_7" Then MsgBox(16,"Wrong OS Version","This program can only be ran from Windows 7.") Exit EndIf ;Make sure Microsoft WAIK is installed ;===================================== If FileExists ($WAIKFolder) = 0 Then $iMsgBoxAnswer = MsgBox(20,"Installation Not Found","Could not locate Microsoft WAIK installation. Would you like to browse for its location?") Select Case $iMsgBoxAnswer = 6 $SelectFolder = FileSelectFolder("Select Folder Location Of Windows AIK", "" , 2) $SourceFolder = ($SelectFolder & "\Tools\PETools") Case $iMsgBoxAnswer = 7 Exit EndSelect EndIf ;Draw GUI ;======== $PEWizard = GUICreate("PE 3.0 Create Wizard", 642, 464, -1, -1) $Group1 = GUICtrlCreateGroup("CPU Architecture", 8, 16, 305, 105) $Radio1 = GUICtrlCreateRadio("x86", 24, 40, 169, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Radio2 = GUICtrlCreateRadio("ia64", 24, 64, 169, 17) $Radio3 = GUICtrlCreateRadio("amd64", 24, 88, 121, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlSetTip(-1, "Choose the CPU architecture of the PC that PE will boot from.") $Group2 = GUICtrlCreateGroup("RAMDisk Settings", 328, 16, 305, 105) $Combo1 = GUICtrlCreateCombo("32", 488, 40, 65, 25) GUICtrlSetData(-1, "64|128|256|512") $Label1 = GUICtrlCreateLabel("Scratch Space:", 384, 40, 78, 17) GUICtrlSetTip(-1, "This sets the amount of space set aside for any programs in your PE environment that require writing to a temp file.") $Combo2 = GUICtrlCreateCombo("C", 520, 80, 33, 25) GUICtrlSetData(-1, "D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z") $Label2 = GUICtrlCreateLabel("PE Drive Letter:", 384, 80, 79, 17) GUICtrlSetTip(-1, "This is the drive letter that the PE environment (Boot.wim) will be assigned to.") GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Packages", 8, 136, 625, 265) $Checkbox1 = GUICtrlCreateCheckbox("Fonts - Additional font support.", 24, 161, 177, 25) GUICtrlSetTip(-1, "Additional font support for the following languages: ja-JP, ko-KR, zh-CN, zh-HK, and zh-TW.") $Checkbox2 = GUICtrlCreateCheckbox("HTA - HTML Application support.", 24, 201, 185, 25) GUICtrlSetTip(-1, "Enables the creation of GUI applications using the Internet Explorer script engine and HTML services.") $Checkbox3 = GUICtrlCreateCheckbox("Legacy Setup - The Media Setup feature package.", 24, 241, 265, 25) GUICtrlSetTip(-1, "All Setup files from the \Sources folder on the Windows media. Add this package when servicing Setup or the \Sources folder on the Windows media. Must be added with the Setup feature package. To add a new Boot.wim to the media, add either child package in addition to the Setup and Media packages. This package is required to support Windows Server® 2008 R2 installation.") $Checkbox4 = GUICtrlCreateCheckbox("MDAC - Microsoft Data Access Component support.", 24, 281, 273, 17) GUICtrlSetTip(-1, "Enables queries to SQL servers with Active Directory Objects (ADO). Example usage: building a dynamic Unattend from unique system information.") $Checkbox5 = GUICtrlCreateCheckbox("PPPoE - Enables Point-to-Point Protocol over Ethernet support.", 24, 321, 321, 17) GUICtrlSetTip(-1, "Create, connect, disconnect and delete PPPoE connections from Windows PE.") $Checkbox6 = GUICtrlCreateCheckbox("Scripting - Windows Script Host (WSH) support.", 24, 361, 249, 17) GUICtrlSetTip(-1, "Enables batch file processing using WSH script objects.") $Checkbox7 = GUICtrlCreateCheckbox("Setup - The Setup feature package (parent).", 352, 161, 233, 17) GUICtrlSetTip(-1, "All Setup files from the \Sources folder common to Client and Server.") $Checkbox8 = GUICtrlCreateCheckbox("Setup Client - Client Setup feature package (child).", 352, 201, 257, 17) GUICtrlSetTip(-1, "The Client branding files for Setup. Must be added after the Setup feature package.") $Checkbox9 = GUICtrlCreateCheckbox("Setup Server - Server Setup feature package (child).", 352, 241, 265, 17) GUICtrlSetTip(-1, "The Server branding files for Setup. Must be added after the Setup feature package.") $Checkbox10 = GUICtrlCreateCheckbox("WMI - Windows Management Instrumentation.", 352, 281, 265, 17) GUICtrlSetTip(-1, "A subset of the WMI providers that enables minimal system diagnostics.") $Checkbox11 = GUICtrlCreateCheckbox("WDS Tools - Windows Deployment Services tools.", 352, 321, 265, 17) GUICtrlSetTip(-1, "Includes APIs to enable a multicast scenario with a custom Windows Deployment Services client and Image Capture utility.") GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Create", 536, 416, 97, 33, $WS_GROUP) $Progress1 = GUICtrlCreateProgress(16, 424, 425, 17) $Label3 = GUICtrlCreateLabel("", 464, 424, 53, 17) GUISetState(@SW_SHOW) ;Main loop ;========= While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox3 If GUICtrlRead ($Checkbox3) = 1 Then GUICtrlSetState ($Checkbox7, $GUI_CHECKED) EndIf Case $Checkbox8 If GUICtrlRead ($Checkbox8) = 1 Then GUICtrlSetState ($Checkbox7, $GUI_CHECKED) EndIf Case $Checkbox9 If GUICtrlRead ($Checkbox9) = 1 Then GUICtrlSetState ($Checkbox7, $GUI_CHECKED) EndIf Case $Button1 _Create() EndSwitch WEnd Func _Create() GUICtrlSetData ($Label3, "Working...") If GUICtrlRead ($Radio1) = 1 Then $Arch = "x86" If GUICtrlRead ($Radio2) = 1 Then $Arch = "ia64" If GUICtrlRead ($Radio3) = 1 Then $Arch = "amd64" If GUICtrlRead ($Checkbox1) = 1 Then $Font = 1 If GUICtrlRead ($Checkbox2) = 1 Then $HTA = 1 If GUICtrlRead ($Checkbox3) = 1 Then $LegacySetup = 1 If GUICtrlRead ($Checkbox4) = 1 Then $MDAC = 1 If GUICtrlRead ($Checkbox5) = 1 Then $PPPoE = 1 If GUICtrlRead ($Checkbox6) = 1 Then $Scripting = 1 If GUICtrlRead ($Checkbox7) = 1 Then $Setup = 1 If GUICtrlRead ($Checkbox8) = 1 Then $SetupClient = 1 If GUICtrlRead ($Checkbox9) = 1 Then $SetupServer = 1 If GUICtrlRead ($Checkbox10) = 1 Then $WMI = 1 If GUICtrlRead ($Checkbox11) = 1 Then $WDS = 1 $Scratch = GUICtrlRead ($Combo1) $DriveLetter = GUICtrlRead ($Combo2) $DestFolder = ("C:\WinPE_" & $Arch) If DirGetSize ($DestFolder) = -1 Then DirCreate ($DestFolder) If DirGetSize ($DestFolder) > 0 Then $iMsgBoxAnswer = MsgBox(52,"Folder Already Exists","PE Wizard is attempting to create the following directory:" & @CRLF & @CRLF & $DestFolder & @CRLF & @CRLF & "It appears to already exist and contains data. Is it OK to overwrite?" & @CRLF, 0, $PEWizard) Select Case $iMsgBoxAnswer = 6 DirRemove ($DestFolder, 1) DirCreate ($DestFolder) Case $iMsgBoxAnswer = 7 Return EndSelect EndIf ;Extract chosen version of PE to $DestFolder ;=========================================== If DirCreate ($DestFolder & "\ISO") = 0 Then _DirCreateError() If DirCreate ($DestFolder & "\mount") = 0 Then _DirCreateError() If FileExists ($SourceFolder & "\" & $Arch & "\bootmgr") = 1 Then $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\bootmgr", $DestFolder & "\ISO\bootmgr") If $Stat = 0 Then _FileCopyError() EndIf If FileExists ($SourceFolder & "\" & $Arch & "\bootmgr.efi") = 1 Then $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\bootmgr.efi", $DestFolder & "\ISO\bootmgr.efi") If $Stat = 0 Then _FileCopyError() EndIf If FileExists ($SourceFolder & "\" & $Arch & "\boot\etfsboot.com") = 1 Then $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\boot\etfsboot.com", $DestFolder & "\etfsboot.com") If $Stat = 0 Then _FileCopyError() EndIf If FileExists ($SourceFolder & "\" & $Arch & "\boot\efisys.bin") = 1 Then $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\boot\efisys.bin", $DestFolder & "\efisys.bin") If $Stat = 0 Then _FileCopyError() EndIf If FileExists ($SourceFolder & "\" & $Arch & "\boot\efisys_noprompt.bin") = 1 Then $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\boot\efisys_noprompt.bin", $DestFolder & "\efisys_noprompt.bin") If $Stat = 0 Then _FileCopyError() EndIf If FileExists ($SourceFolder & "\" & $Arch & "\boot") = 1 Then $Stat = DirCopy ($SourceFolder & "\" & $Arch & "\boot", $DestFolder & "\ISO\boot",1) If $Stat = 0 Then _FileCopyError() EndIf If FileExists ($SourceFolder & "\" & $Arch & "\EFI") = 1 Then $Stat = DirCopy ($SourceFolder & "\" & $Arch & "\EFI", $DestFolder & "\ISO\EFI",1) If $Stat = 0 Then _FileCopyError() EndIf If DirCreate ($DestFolder & "\ISO\sources") = 0 Then _DirCreateError() $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\winpe.wim", $DestFolder & "\winpe.wim") If $Stat = 0 Then _FileCopyError() GUICtrlSetData ($Progress1, 20) ;Mount WinPE.wim so we can add packages and settings ;=================================================== $Stat = RunWait ("DISM.exe /Mount-WIM /WimFile:" & $DestFolder & "\winpe.wim /index:1 /MountDir:" & $DestFolder & "\mount", "", @SW_HIDE); Mount winpe.wim If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 25) ;Set scratch space ;================= $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Set-ScratchSpace:" & $Scratch, "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 30) ;Set target path (drive letter) ;============================== $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Set-TargetPath:" & $DriveLetter & ":\", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 35) ;Begin package installations ;=========================== $PackageFolder = ($SourceFolder & "\" & $Arch & "\WinPE_FPs") If $Font = 1 Then;<=== Font packages $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\lp_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-ja-jp.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-ko-kr.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-zh-cn.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-zh-hk.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-zh-tw.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 40) EndIf If $HTA = 1 Then;<=== HTA package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-hta_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-hta.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 45) EndIf If $LegacySetup = 1 Then;<=== Legacy Setup package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-legacysetup_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-legacysetup.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 50) EndIf If $MDAC = 1 Then;<=== MDAC package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-mdac_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-mdac.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 55) EndIf If $PPPoE = 1 Then;<=== PPPoE package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-PPPOE_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-pppoe.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 60) EndIf If $Scripting = 1 Then;<=== Scripting package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-scripting_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-scripting.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 65) EndIf If $Setup = 1 Then;<=== Setup package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-setup_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-setup.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 70) EndIf If $SetupClient = 1 Then;<=== SetupClient package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-setup-client_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-setup-client.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 75) EndIf If $SetupServer = 1 Then;<=== SetupServer package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-setup-server_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-setup-server.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 80) EndIf If $WMI = 1 Then;<=== WMI package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-wmi_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-wmi.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 85) EndIf If $WDS = 1 Then;<=== WDS package $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-wds-tools_en-us.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-wds-tools.cab", "", @SW_HIDE) If $Stat = 0 And @Error Then _DISMError() GUICtrlSetData ($Progress1, 90) EndIf ;Record ID settings in WinPE INI file ;==================================== IniWrite ($DestFolder & "\ISO\winpe", "ID", "Arch", $Arch) IniWrite ($DestFolder & "\ISO\winpe", "ID", "DriveLetter", $DriveLetter) IniWrite ($DestFolder & "\ISO\winpe", "ID", "ScratchSpace", $Scratch) $INIFile = FileOpen ($DestFolder & "\ISO\WinPE", 1) FileWriteLine($INIFile, @CRLF) FileClose ($INIFile) If $Font = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Fonts", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Fonts", "0") EndIf If $HTA = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "HTA", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "HTA", "0") EndIf If $LegacySetup = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "LegacySetup", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "LegacySetup", "0") EndIf If $MDAC = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "MDAC", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "MDAC", "0") EndIf If $PPPoE = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "PPPoE", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "PPPoE", "0") EndIf If $Scripting = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Scripting", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Scripting", "0") EndIf If $Setup = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Setup", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Setup", "0") EndIf If $SetupClient = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "SetupClient", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "SetupClient", "0") EndIf If $SetupServer = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "SetupServer", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "SetupServer", "0") EndIf If $WMI = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "WMI", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "WMI", "0") EndIf If $WDS = 1 Then IniWrite ($DestFolder & "\ISO\winpe", "Packages", "WDS", "1") Else IniWrite ($DestFolder & "\ISO\winpe", "Packages", "WDS", "0") EndIf GUICtrlSetData ($Progress1, 95) $Stat = RunWait ("DISM.exe /Unmount-WIM /MountDir:" & $DestFolder & "\mount /Commit", "", @SW_HIDE); Unmount and commit changes If $Stat = 0 And @Error Then _DISMError() $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\winpe.wim", $DestFolder & "\ISO\sources\boot.wim");<=== This should be the last thing you do after unmounting the WIM If $Stat = 0 Then _FileCopyError() GUICtrlSetData ($Progress1, 100) GUICtrlSetData ($Label3, "Done.") MsgBox(64,"Success","Your PE environment was successfully built.", 0, $PEWizard) GUICtrlSetData ($Progress1, 0) GUICtrlSetData ($Label3, "") EndFunc Func _DirCreateError() MsgBox(16,"Unable To Create Folder","There was an error in the folder creation process." & @CRLF & "Template creation is incomplete.",0, $PEWizard) Exit EndFunc Func _FileCopyError() MsgBox(16,"Unable To Copy File","There was an error in the file copy process." & @CRLF & "Template creation is incomplete.",0, $PEWizard) Exit EndFunc Func _DISMError() MsgBox(16,"DISM Error","DISM returned an error and was unable to complete any changes specified to the boot.wim. Template creation is incomplete.",0, $PEWizard) RunWait ("DISM.exe /Unmount-WIM /MountDir:" & $DestFolder & "\mount /Discard", "", @SW_HIDE) Exit EndFunc
  5. I doubt anyone is interested, but here is the solution I came up with for the above problem (with a heaping help from Zedna): #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $Form1 = GUICreate("Unpack", 419, 244, -1, -1) $Input1 = GUICtrlCreateInput("", 16, 40, 385, 21) $Button1 = GUICtrlCreateButton("Search", 336, 72, 65, 25, 0) $Label1 = GUICtrlCreateLabel("GRP File:", 16, 16, 49, 17) $Input2 = GUICtrlCreateInput("", 16, 136, 385, 21) $Label2 = GUICtrlCreateLabel("Folder to unpack to:", 16, 112, 99, 17) $Button2 = GUICtrlCreateButton("Search", 336, 168, 65, 25, 0) $Button3 = GUICtrlCreateButton("Extract", 169, 192, 89, 33, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $GrpFile = FileOpenDialog("Choose GRP file to extract from", @ScriptDir & "\", "GRP Files (*.grp)", 1 + 2) GUICtrlSetData($Input1, $GrpFile) Case $Button2 $GrpFolder = FileSelectFolder("Choose a folder to extract to", "", 1) GUICtrlSetData($Input2, $GrpFolder) Case $Button3 $File = GUICtrlRead($Input1) $Folder = GUICtrlRead($Input2) GUIDelete($Form1) ExitLoop EndSwitch WEnd Dim $Pos, $Bytes, $sFile, $hFile $tBuffer = DLLStructCreate("char[12]") $iBuffer = DLLStructCreate("int") ;Open and check if file opened for reading OK $GrpFile = _WinAPI_CreateFile($File, 2, 2) If $GrpFile = 0 Then MsgBox(0, "Error", "Unable to open file.") Return EndIf ;Read first 12 bytes for ID _WinAPI_ReadFile($GrpFile, DLLStructGetPtr($tBuffer), 12, $Bytes) $FileID = DLLStructGetData($tBuffer, 1) $Pos += 12 ;If $FileID does not = "KenSilverman" then file is not a true GRP If $FileID <> "KenSilverman" Then Exit EndIf ;Read next four bytes as long integer for total number of files contained _WinAPI_SetFilePointer($GrpFile, $Pos) _WinAPI_ReadFile($GrpFile, DLLStructGetPtr($iBuffer), 4, $Bytes) $TotalNumFiles = DLLStructGetData($iBuffer, 1) $Pos += 4 ProgressOn("Extracting", "Filename", "0 percent") Dim $IntFile[$TotalNumFiles + 1] Dim $FileLen[$TotalNumFiles + 1] $IntFile[0] = $TotalNumFiles For $T = 1 To $TotalNumFiles ;Read next 12 bytes for filename of first file _WinAPI_SetFilePointer($GrpFile, $Pos) _WinAPI_ReadFile($GrpFile, DLLStructGetPtr($tBuffer), 12, $Bytes) $FileName = DLLStructGetData($tBuffer, 1) $IntFile[$T] = $FileName $Pos += 12 ;Read next 4 bytes as long integer for file length _WinAPI_SetFilePointer($GrpFile, $Pos) _WinAPI_ReadFile($GrpFile, DLLStructGetPtr($iBuffer), 4, $Bytes) $FileLength = DLLStructGetData($iBuffer, 1) $FileLen[$T] = $FileLength $Pos += 4 Next ;Write archived files to selected folder For $L = 1 To $TotalNumFiles ;Read each packed file in archive to $ExFile buffer _WinAPI_SetFilePointer($GrpFile, $Pos) $fBuffer = DLLStructCreate("byte[" & $FileLen[$L] & "]") _WinAPI_ReadFile($GrpFile, DLLStructGetPtr($fBuffer), $FileLen[$L], $Bytes) $ExFile = DLLStructGetData($fBuffer, 1) ;<=== Buffer that holds current file $Pos += $FileLen[$L] ;Write packed file to selected folder as $IntFile filename $sFile = ($Folder & "\" & $IntFile[$L]) DLLStructSetData($fBuffer, 1, $ExFile) $hFile = _WinAPI_CreateFile($sFile, 1) _WinAPI_WriteFile($hFile, DLLStructGetPtr($fBuffer), $FileLen[$L], $Bytes) _WinAPI_CloseHandle($hFile) $Perc = Round(($L/$TotalNumFiles * 100), 0) ProgressSet($Perc, $Perc & " percent", $IntFile[$L]) Next $fBuffer = 0 $tBuffer = 0 $iBuffer = 0 $Pos = 0 _WinAPI_CloseHandle($GrpFile) ProgressOff ( ) In order for this to run correctly you will need to add the contents of Zedna's files above to your Constants.au3 and WinAPI.au3 files in your Includes folder. And, of course, you will need a GRP file from DukeNukem. This will be incorporated into the launcher I am writing for EDuke32. Anyone interested in running Duke3D natively in Windows (without DosBox) you should check it out here: https://eduke32.com I know it's an old game but I've got a soft spot for the classics. Enjoy.
  6. OK. Most of you will think this a pointless experiment but I was just curious to see if it could be done in AutoIt. The 3D shooter, Duke Nukem 3D, that came out in the mid 90's, used a type of archive for storing it's resource files. It was called a .GRP file or a Group file. The engine author, Ken Silverman, needed a quick and dirty way of consolidating the sound, music and art files and so he came up with this convention. The file format for a .GRP file is as follows: Bytes 0-11 = 12 byte array or 12 byte ID which is "KenSilverman" Bytes 12-15 = long integer (4 bytes) which is total number of files contained in .GRP file (X number of files) Then we have X number of records in the following format: Bytes 16-27 = 12 byte array for filename (this would be the first filename in the group. I imagine it is only 12 bytes because of the older naming convention: 8.3 or xxxxxxxx.xxx Bytes 28-31 = long integer (4 bytes) which is the length of the first file in bytes. And so on. Etc. Finally, after the index, we have X number of file data, stored in respect to the order of the filenames, one after the other, back to back. In short, it is just an uncompressed archive of data! (This was taken from the official 3Drealms site). Soooo...... I have attempted to see if I could write an AutoIt script that could at least SEE what was contained in a .GRP file. From there I thought about making my own extractor but that is down the road a bit. Here is my code so far: CODEDim $B[5] $File = "MY.GRP" $Result = FileOpen ("Result.txt", 1) ; Open and check if file opened for reading OK $GrpFile = FileOpen($File, 0) If $GrpFile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read first 12 bytes for ID $FileID = FileRead($GrpFile, 12) ; If $FileID does not = "KenSilverman" then file is not a true GRP If $FileID <> "KenSilverman" Then MsgBox(16,"Error","This does not appear to be a genuine .GRP file.") Exit EndIf FileWriteLine ($Result, "Group file: " & $File & @CRLF) FileWriteLine ($Result, "File ID: " & $FileID & @CRLF) ; Read next four bytes as long integer for total number of files contained For $L = 1 to 4 $B[$L] = Asc(FileRead($GrpFile, 1)) Next $Hex = Hex($B[4],2) & Hex($B[3],2) & Hex($B[2],2) & Hex($B[1],2) $TotalNumFiles = Dec($Hex) FileWriteLine ($Result, "Total Number of Files: " & $TotalNumFiles & @CRLF & @CRLF) For $T = 1 To $TotalNumFiles Dim $B[5] ; Read next 12 bytes for filename of first file $FileName = FileRead($GrpFile, 12) ; Read next 4 bytes as long integer for file length For $L = 1 to 4 $B[$L] = Asc(FileRead($GrpFile, 1)) Next $Hex = Hex($B[4],2) & Hex($B[3],2) & Hex($B[2],2) & Hex($B[1],2) $FileLength = Dec($Hex) FileWriteLine ($Result, $FileName & "," & $FileLength & @CRLF) Next FileClose($GrpFile) FileClose($Result) Essentially, I run this from the same folder where my MY.GRP is located and it creates a text file named RESULTS.TXT. Well, here are the results when I run this script: Group file: MY.GRP File ID: KenSilverman Total Number of Files: 4 TILES014.ART,1207332 W2DDEFS.CON ARWOLF.MAP MACHAMB.VOC What it SHOULD be displaying is filename, then a comma, then the file length or byte size. As you can see, it displays the byte size for the first file and then nothing for the rest. It seems to read the filenames correctly but not the file size. Of course, when I decide to write an extractor for these files I would need to know the correct position in the file where it's located and how long each file is bytewise. Yes, I know, the game came with it's own handlers (KGROUP.EXE and KEXTRACT.EXE). Like I said, probably a waste of time, but I just wanted to see if it could be done in AutoIt. If some kind soul out there would have the time to take a look at this I would greatly appreciate it. I've included a sample .GRP file. It's in a zip file called MY.zip. I'm using AutoIt version 3.3.0.0 if that helps any. I think my lack of knowledge of how AutoIt reads an open file is to blame but I'm just not sure where I'm going wrong. MY.zip
  7. Don't know if anyone has heard of this site: http://www.windowsupdatesdownloader.com/ (WUD) essentially downloads updates and stores them locally on your machine. It does not install them, though. It's kind of a poor man's WSUS. What would be really cool is to be able to incorporate this script with a cache of updates already downloaded. Could cut system building times in half. I know - if you want it go build it. I'm already pulling the script apart to see if that could be done. Excellent work and kudos to original poster.
  8. Ah, I see. Sorry. Unfortunatly, it's been a while since I've messed with UAC as it was the first thing I turned off when I installed Vista.
  9. I might be misinterpreting but I believe #requireadmin ensures that the script will ONLY run if the person who executes it has admin privileges. If there is a chance that your user does not have admin privileges you could use RunAs().
  10. I am using AutoIt 3.2.12.1. It comes with a huge library of UDF's. One of the functions called in this script is named SQLite.dll.au3. This creates the file SQLite3.dll in your Windows system directory if it is not already there. This library is what handles all of the SQL calls in this script. This should be all you need. (Except of course, James3mg's script from the first page of this message as well).
  11. Well, I played around with this last night and it seems to be working great. ReadSection and ReadSectionNames returns arrays perfectly. I was able to hand off an array to WriteSection. All other Read and Write functions act normally. All in all, this UDF performs identically to the internal Au3 INI functions with the exception of utilizing a database instead of a plain text file. James3mg, my hat's off to you.
  12. James3mg, Running Au3 version 3.2.12.1 on Vista. Here are a couple of samples I've tried: CODE#include <DB_Ini.au3> $File = (@ScriptDir & "\Users.ini") $Write = _DBIniWrite($File, "tfl0001", "FullName", "Trident Foods Store # 1") msgbox(0,"", $Write) $Read = _DBIniRead($File, "tfl0001", "FullName", "None") msgbox(0,"", $Read) CODE$File = (@ScriptDir & "\Users.ini") $Write = IniWrite($File, "tfl0001", "FullName", "Trident Foods Store # 1") msgbox(0,"", $Write) $Read = IniRead($File, "tfl0001", "FullName", "None") msgbox(0,"", $Read) I copied your code from the forum page, called it "DB_Ini.au3" and placed that in my includes folder. I know my samples are pretty elementary so please forgive me. When I run the first piece of code the first msgbox returns "0" and the second msgbox returns "None". This is the debug that Scite outputs when I run it from there: CODE! SQLite.au3 Error --> Function: _SQLite_Exec --> Query: CREATE TABLE IF NOT EXISTS ''tfl0001'' ('key' UNIQUE ON CONFLICT REPLACE NOT NULL,'value') --> Error: near "tfl0001": syntax error ! SQLite.au3 Error --> Function: _SQLite_GetTable2d or _SQLite_QuerySingleRow or _SQLite_Exec --> Query: SELECT 'value' FROM ''tfl0001'' WHERE 'key' = ''FullName'' --> Error: near "''": syntax error The second piece of code is strict Au3 and returns "1" and "Trident Foods Store # 1" as I would expect. I made sure that "SQLLite3.dll" is created in my System folder. I'm not up to snuff on databases so could you please tell me if I am doing something incorrectly? I would greatly appreciate it. I think this function is a wonderful idea and would help out a lot of fledgling DB users like myself. Thanks.
  13. JPam, This function just gets better and better. I really love the ability of using a file for a key. Many thanks for this wonderful contribution! PS Using this on Vista. Tried compress and encrypt on plain text files. Works like a charm. I did notice in your comments about not using a pre-compressed file like a .JPG or .ZIP. Was curious about that but no big deal. It works perfectly for what I need it for.
  14. jpam... Just tried the newest version. Using Vista Ultimate. Encrypted/decrypted .txt, .jpg and .zip files. Works like a charm. Excellent work.
×
×
  • Create New...