From ecf42f35627698d383568a4f4ccc8e3577165781 Mon Sep 17 00:00:00 2001 From: Homes32 Date: Wed, 5 Jan 2022 18:22:47 -0600 Subject: [PATCH] Extended RegUnloadHives to accept Target= and HKEY= parameters minor script updates, option to reset source during nuke --- .../Applications/Multimedia/IrfanView.script | 2 +- Projects/PhoenixPE/Components/DotNET.script | 6 +- .../Drivers/DriverIntegration.script | 10 ++-- .../Tools}/DriverInjection.script | 8 +-- .../Media Creation/Tools/Ventoy.script | 6 +- Projects/PhoenixPE/PhoenixAPI.script | 57 +++++++++++++++++-- Projects/PhoenixPE/Testing/VMWare.script | 2 +- Projects/PhoenixPE/Toolbox/Features.script | 3 +- .../PhoenixPE/Toolbox/ScriptFactory.script | 7 +-- Projects/PhoenixPE/script.project | 33 ++++++----- 10 files changed, 94 insertions(+), 40 deletions(-) rename Projects/PhoenixPE/{Toolbox => Drivers/Tools}/DriverInjection.script (99%) diff --git a/Projects/PhoenixPE/Applications/Multimedia/IrfanView.script b/Projects/PhoenixPE/Applications/Multimedia/IrfanView.script index e71a24d..03ef052 100644 --- a/Projects/PhoenixPE/Applications/Multimedia/IrfanView.script +++ b/Projects/PhoenixPE/Applications/Multimedia/IrfanView.script @@ -62,7 +62,7 @@ ExtractAllFiles,%ScriptFile%,Lang,"%TargetPrograms%\%ProgramFolder%\Languages" // Settings StrFormat,REPLACE,%ProgramExe%,".exe",".ini",%SettingsFile% -FileCreateBlank,"%TargetPrograms%\%ProgramFolder%\%SettingsFile%",UTF16 +FileCreateBlank,"%TargetPrograms%\%ProgramFolder%\%SettingsFile%",Encoding=UTF16 // Toolbar IniWrite,"%TargetPrograms%\%ProgramFolder%\%SettingsFile%","Toolbar","Skin","Grosberg_24.png" diff --git a/Projects/PhoenixPE/Components/DotNET.script b/Projects/PhoenixPE/Components/DotNET.script index c588ff7..1b5e6fe 100644 --- a/Projects/PhoenixPE/Components/DotNET.script +++ b/Projects/PhoenixPE/Components/DotNET.script @@ -175,7 +175,8 @@ End Else,Message,".NET Framework 3 is already enabled!",Warning // Dism doesn't always unload hives correctly. Force unload just to make sure WimUnmout doesn't freak out. -ShellExecute,Hide,%Tools%\x86\HiveUnload.exe,"/HKLM /Target:%TargetSystem32%\config" +RegUnloadHives,Force,"Target=%TargetSystem32%\config" + Echo,"Committing changes and unmounting source image:#$x [%SourceInstallWim%]...#$x#$xThis can take awhile, please be patient." WimUnmount,%MountDir%,COMMIT @@ -219,7 +220,8 @@ End Else,Message,".NET Framework 3 is already disabled!",Warning // Dism doesn't always unload hives correctly. Force unload just to make sure WimUnmout doesn't freak out. -ShellExecute,Hide,%Tools%\x86\HiveUnload.exe,"/HKLM /Target:%TargetSystem32%\config" +RegUnloadHives,Force,"Target=%TargetSystem32%\config" + Echo,"Committing changes and unmounting source image:#$x [%SourceInstallWim%]...#$x#$xThis can take awhile, please be patient." WimUnmount,%MountDir%,COMMIT diff --git a/Projects/PhoenixPE/Drivers/DriverIntegration.script b/Projects/PhoenixPE/Drivers/DriverIntegration.script index 3c3a94f..902cd68 100644 --- a/Projects/PhoenixPE/Drivers/DriverIntegration.script +++ b/Projects/PhoenixPE/Drivers/DriverIntegration.script @@ -83,7 +83,7 @@ Else,Set,%DismForceUnsigned%,"" ShellExecute,Hide,"Dism.exe","/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriversSrc%#$q /recurse /LogPath:#$q%DismLog%#$q%DismForceUnsigned%" If,Not,%ExitCode%,Equal,0,Halt,"Error: Dism.exe terminated with error code: [%ExitCode%]. Check the log for details." // Dism doesn't always unload hives correctly. Force unload just to make sure. -ShellExecute,Hide,%Tools%\x86\HiveUnload.exe,"/HKLM /Target:%TargetSystem32%\config" +RegUnloadHives,Force,"Target=%TargetSystem32%\config" [#ExportHostDrivers-ExportHostDrv#] // =============================================================================================================================== @@ -326,11 +326,11 @@ btn_ScriptInfo=,1,8,556,5,25,25,ShowScriptInfo,Help_16.png,True,"__Script Info" bvl_DriverSource="Driver Packages",1,12,5,50,575,180,8,Bold lbl_DriverPackagesNote="Please specify the path to the directory containing the drivers you wish to integrate.#$x#$xYou may also use the buttons above to export drivers from your host computer and integrate them into your build.#$x#$xDriver packages must be decompressed (*.ini). Sub-Folders are allowed.",1,1,14,66,559,62,8,Normal lbl_DriversX86="x86 Drivers",1,1,17,141,70,16,8,Bold -fb_DriversX86=%BaseDir%\Workbench\Drivers\x86,1,13,84,135,458,20,dir,"Title=Select the directory containing your uncompressed x86 (32bit) drivers","__The directory containing uncompressed x86 (32bit) drivers." -btn_BrowseX86=,1,8,549,135,20,20,BrowseX86,OpenFolder_16.png,True,"__Browse" +fb_DriversX86=%BaseDir%\Workbench\Drivers\x86,1,13,84,135,460,20,dir,"Title=Select the directory containing your uncompressed x86 (32bit) drivers","__The directory containing uncompressed x86 (32bit) drivers." +btn_BrowseX86=,1,8,549,135,20,20,BrowseX86,OpenFolder_16.png,True,__Browse lbl_DriversX64="x64 Drivers",1,1,17,172,70,16,8,Bold -fb_DriversX64=%BaseDir%\Workbench\Drivers\x64,1,13,84,166,458,20,dir,"Title=Select the directory containing your uncompressed x64 (64bit) drivers","__The directory containing uncompressed x64 (64bit) drivers." -btn_BrowseX64=,1,8,549,166,20,20,BrowseX64,OpenFolder_16.png,True,"__Browse" +fb_DriversX64=%BaseDir%\Workbench\Drivers\x64,1,13,84,166,460,20,dir,"Title=Select the directory containing your uncompressed x64 (64bit) drivers","__The directory containing uncompressed x64 (64bit) drivers." +btn_BrowseX64=,1,8,549,166,20,20,BrowseX64,OpenFolder_16.png,True,__Browse cb_LoadDriversOnStartup="Load Drivers At Startup",1,3,17,200,139,16,True cb_ForceUnsignedDrivers="Force Install Unsigned Drivers (x64)",0,3,167,200,200,18,False,"__Caution: See Notes below" cb_PatchDrvInst="Bypass Catalog Signature Check",0,3,380,200,173,18,False,"__Patch Drvinst.exe to disable signature checking for catalog files.#$xAmong other things this allows you to use modified *.inf files." diff --git a/Projects/PhoenixPE/Toolbox/DriverInjection.script b/Projects/PhoenixPE/Drivers/Tools/DriverInjection.script similarity index 99% rename from Projects/PhoenixPE/Toolbox/DriverInjection.script rename to Projects/PhoenixPE/Drivers/Tools/DriverInjection.script index c251fd5..721ffcc 100644 --- a/Projects/PhoenixPE/Toolbox/DriverInjection.script +++ b/Projects/PhoenixPE/Drivers/Tools/DriverInjection.script @@ -32,7 +32,7 @@ Title=Driver Injection Description=Inject drivers into an existing boot.wim image. Author=Homes32 -Level=10 +Level=6 Selected=None Mandatory=False Version=1.0.0.0 @@ -64,7 +64,7 @@ If,ExistFile,%fb_WimImage%,Begin // Inject Drivers Run,%ScriptFile%,IntegrateDrivers // Optimize Image (Keep original compression) - Echo,"Optimizing Boot.wim..." + Echo,"Optimizing image..." WimOptimize,%fb_WimImage%,ReComp=KEEP // Done. Echo,"Driver integration finished." @@ -105,7 +105,7 @@ ShellExecute,Hide,"Dism.exe","/image:#$q%MountDir%#$q /Add-Driver /Driver:#$q%fb If,Not,%ExitCode%,Equal,0,Halt,"Error: Dism.exe terminated with error code: [%ExitCode%]. Check the log for details." // Dism doesn't always unload hives correctly. Force unload just to make sure WimUnmout doesn't freak out. -ShellExecute,Hide,%Tools%\x86\HiveUnload.exe,"/HKLM /Target:%MountDir%\Windows\System32\config" +RegUnloadHives,Force,"Target=%MountDir%\Windows\System32\config" // Unmount Echo,"Committing changes and unmounting source image:#$x [%fb_WimImage%]...#$x#$xThis can take awhile, please be patient." @@ -224,7 +224,7 @@ btn_ScriptInfo=,1,8,556,5,25,25,ShowScriptInfo,Help_16.png,True,"__Script Info" lbl_DriverSourceInfo="Please specify the path to the directory containing the drivers you wish to integrate.#$x#$xDriver packages must be decompressed (*.ini). Sub-Folders are allowed.",1,1,14,66,559,36,8,Normal bvl_DriverSource="Driver Packages",1,12,5,50,575,180,8,Bold lbl_DriversSrc=Drivers,1,1,17,111,70,16,8,Bold -fb_DriversSrc=%BaseDir%\Workbench\Drivers\x64,1,13,84,105,458,20,dir,"Title=Select the directory containing your uncompressed drivers","__The directory containing uncompressed drivers." +fb_DriversSrc=%BaseDir%\Workbench\Drivers\x64,1,13,84,105,460,20,dir,"Title=Select the directory containing your uncompressed drivers","__The directory containing uncompressed drivers." btn_BrowseDriversSrc=,1,8,549,105,20,20,BrowseDrvSource,OpenFolder_16.png,True,__Browse lbl_WimImageInfo="Please specify the path to your existing boot.wim image.",1,1,14,148,282,16,8,Normal lbl_WimImage="Wim Image",1,1,17,172,70,16,8,Bold diff --git a/Projects/PhoenixPE/Media Creation/Tools/Ventoy.script b/Projects/PhoenixPE/Media Creation/Tools/Ventoy.script index f69aaf6..97cc0e5 100644 --- a/Projects/PhoenixPE/Media Creation/Tools/Ventoy.script +++ b/Projects/PhoenixPE/Media Creation/Tools/Ventoy.script @@ -30,19 +30,19 @@ [Main] Title=Ventoy -Description=(v1.0.62) Ventoy is an open source tool used to create bootable USB devices capable of launching multiple ISO/WIM/IMG/VHD(x)/EFI files. +Description=(v1.0.63) Ventoy is an open source tool used to create bootable USB devices capable of launching multiple ISO/WIM/IMG/VHD(x)/EFI files. Author=Homes32 Level=8 Selected=None Mandatory=False Version=1.1.9.0 -Date=2021-12-10 +Date=2021-12-20 Interface=Interface [Variables] %ProgramFolder%="%Workbench%\Ventoy" %ProgramExe%="Ventoy2Disk.exe" -%ProgramVer%="1.0.62" +%ProgramVer%="1.0.63" %DownloadURL%=https://github.com/ventoy/Ventoy/releases/download/v%ProgramVer%/ventoy-%ProgramVer%-windows.zip %SetupFile%="Ventoy.zip" diff --git a/Projects/PhoenixPE/PhoenixAPI.script b/Projects/PhoenixPE/PhoenixAPI.script index 2ea39d1..bd5089c 100644 --- a/Projects/PhoenixPE/PhoenixAPI.script +++ b/Projects/PhoenixPE/PhoenixAPI.script @@ -115,17 +115,36 @@ RegHiveLoad,Tmp_Install_System,%RegInstallSystem% // =============================================================================================================================== // Name...........: RegUnloadHives // Description....: UnMount Source and Build registry hives. -// Syntax.........: RegUnLoadHives,[FORCE] -// Parameters.....: #1 Force - Force hive unload using HiveUnload.exe +// Syntax.........: RegUnLoadHives[,FORCE][,HKEY=][,Target=] +// Parameters.....: Force - Force hive unload using HiveUnload.exe +// HKEY= - Unload hives from this root key. (HKLM, HKU) +// Target= - Unload hives from this directory. // Return values..: ExitCode provided by the HiveUnload.exe application +// 0 - All registry hives unloaded successfully. +// 1 - Not all registry hives could be unloaded. +// 2 - No loaded registry hives were found. +// You must handle ExitCode. The script will not Exit/Halt. // Author.........: Homes32 -// Remarks........: +// Remarks........: HiveUnload.exe is open-source software developed by BlueLife // Related........: // =============================================================================================================================== [_PhoenixAPI_RegUnloadHives] +System,SetLocal -If,#1,Equal,"Force",Begin - If,ExistFile,"%Tools%\x86\HiveUnload.exe",ShellExecute,Hide,"%Tools%\x86\HiveUnload.exe","/HKLM /Target:ALL" +GetParam,1,%Arg1% +GetParam,2,%Arg2% +GetParam,3,%Arg3% + +Set,%ForceUnmount%,False +Set,%HKEY%,"HKLM" +Set,%UnloadTarget%,"ALL" + +Run,%API%,__PhoenixAPI_RegUnloadHives_Process_Arg,%Arg1% +Run,%API%,__PhoenixAPI_RegUnloadHives_Process_Arg,%Arg2% +Run,%API%,__PhoenixAPI_RegUnloadHives_Process_Arg,%Arg3% + +If,%ForceUnmount%,Equal,True,Begin + If,ExistFile,"%Tools%\x86\HiveUnload.exe",ShellExecute,Hide,"%Tools%\x86\HiveUnload.exe","/%HKEY% /Target:%UnloadTarget%" If,%ExitCode%,Equal,0,Echo,"HiveUnload: All registry hives unloaded successfully." If,%ExitCode%,Equal,1,Echo,"HiveUnload: Warning: Not all registry hives could be unloaded! Please verify that regedit is not running and try again.",Warn If,%ExitCode%,Equal,2,Echo,"HiveUnload: No loaded registry hives were found." @@ -141,6 +160,32 @@ Else,Begin RegHiveUnload,Tmp_Install_System End +System,EndLocal + +[#__PhoenixAPI_RegUnloadHives_Process_Arg#] +// =============================================================================================================================== +// Name...........: __PhoenixAPI_RegUnloadHives_Process_Arg +// Description....: Process RegUnloadHives optional arguments +// Syntax.........: __PhoenixAPI_RegUnloadHives_Process_Arg, +// Parameters.....: #1 Arg - The argument to process +// Return values..: +// Author.........: Homes32 +// Remarks........: Internal Function +// Do not call System,SetLocal here. We need this function to run in the same scope as PhoenixAPI_InnoUnpack +// Related........: _PhoenixAPI_RegUnloadHives +// =============================================================================================================================== +[__PhoenixAPI_RegUnloadHives_Process_Arg] + +If,#1,Equal,"Force",Set,%ForceUnmount%,True +Else,Begin + StrFormat,Split,#1,"=",1,%ArgKey% + If,Not,%ArgKey%,Equal,"",Begin + If,%ArgKey%,Equal,"HKEY",StrFormat,Split,#1,"=",2,%HKEY% + Else,If,%ArgKey%,Equal,"TARGET",StrFormat,Split,#1,"=",2,%UnloadTarget% + Else,Halt,"SYNTAX ERROR: Invalid Argument [#1]" + End +End + [#_PhoenixAPI_RegCopyDriver#] // =============================================================================================================================== // Name...........: RegCopyDriver @@ -319,7 +364,7 @@ System,EndLocal // Description....: Process InnoUnpack optional arguments // Syntax.........: __PhoenixAPI_InnoUnpack_Process_Arg, // Parameters.....: #1 Arg - The argument to process -// Return values..: #r - Command line string to be passed to Innounp.exe +// Return values..: // Author.........: Homes32 // Remarks........: Internal Function // Do not call System,SetLocal here. We need this function to run in the same scope as PhoenixAPI_InnoUnpack diff --git a/Projects/PhoenixPE/Testing/VMWare.script b/Projects/PhoenixPE/Testing/VMWare.script index 2edce64..5701964 100644 --- a/Projects/PhoenixPE/Testing/VMWare.script +++ b/Projects/PhoenixPE/Testing/VMWare.script @@ -34,7 +34,7 @@ Author=Homes32 Description=Run your ISO in VMware Player/Workstation Version=1.1.1.0 Level=9 -Selected=True +Selected=False Mandatory=False NoWarning=False Date=2021-11-28 diff --git a/Projects/PhoenixPE/Toolbox/Features.script b/Projects/PhoenixPE/Toolbox/Features.script index efaa9cb..8db9ac1 100644 --- a/Projects/PhoenixPE/Toolbox/Features.script +++ b/Projects/PhoenixPE/Toolbox/Features.script @@ -69,7 +69,8 @@ Run,%ScriptFile%,ToggleLinuxSubsystem Run,%ScriptFile%,TogglePrintComponents // Dism doesn't always unload hives correctly. Force unload just to make sure WimUnmout doesn't freak out. -ShellExecute,Hide,%Tools%\x86\HiveUnload.exe,"/HKLM /Target:%TargetSystem32%\config" +RegUnloadHives,Force,"Target=%TargetSystem32%\config" + Echo,"Committing changes and unmounting source image:#$x [%SourceInstallWim%]...#$x#$xThis can take awhile, please be patient." WimUnmount,%MountDir%,COMMIT diff --git a/Projects/PhoenixPE/Toolbox/ScriptFactory.script b/Projects/PhoenixPE/Toolbox/ScriptFactory.script index d69e69e..f5376b7 100644 --- a/Projects/PhoenixPE/Toolbox/ScriptFactory.script +++ b/Projects/PhoenixPE/Toolbox/ScriptFactory.script @@ -36,7 +36,6 @@ Version=1.0.0.0 Level=10 Selected=None Date=2020-07-27 -Interface=Interface Mandatory=False [Variables] @@ -277,15 +276,15 @@ Message,"The Script Factory generates a skeleton framework, giving you a startin // =============================================================================================================================== [Interface] btn_CreateScript="Create Script",1,8,5,5,100,25,CreateScript,play-hot.png,True -btn_SetDefaultOptions=,1,8,390,5,25,25,SetDefaultOptions,SetDefaults_16.png,False,"__Restore Defaults" +btn_SetDefaultOptions=,1,8,390,5,25,25,SetDefaultOptions,SetDefaults_16.png,True,"__Restore Defaults" btn_AdvancedOptions=,1,8,420,5,25,25,ToggleAdvancedOptions,Advanced_16.png,True,"__Show Advanced Options" btn_ScriptInfo=,1,8,450,5,25,25,ShowScriptInfo,Help_16.png,True,"__Script Info" bvl_ScriptTemplate=Template,1,12,5,50,472,71,8,Bold cmb_ScriptTemplate="Simple Download App",1,4,20,69,200,21,"Blank Script","Simple Download App","Simple Embedded App",_UpdateTemplateDescription_,True -lbl_TemplateDescr="A simple script that downloads a program at build time.",1,1,20,100,447,16,8,Normal +lbl_TemplateDescr="A simple script that downloads programs at build time.",1,1,20,100,447,16,8,Normal bvl_ScriptProperties="General Script Information",1,12,5,140,472,157,8,Bold txt_ScriptTitle="Script Title",1,0,20,170,200,21, -txt_ScriptAuthor="Script Author",1,0,235,170,200,21, +txt_ScriptAuthor="Script Author",1,0,265,170,200,21, txt_ScriptDescr="Script Description",1,0,20,215,444,21, lbl_ScriptLevel="Script Level",1,1,20,245,190,16,8,Normal lbl_AdvancedMode="Advanced Mode",0,1,135,245,92,16,8,Bold diff --git a/Projects/PhoenixPE/script.project b/Projects/PhoenixPE/script.project index 59ebfdf..0c912ef 100644 --- a/Projects/PhoenixPE/script.project +++ b/Projects/PhoenixPE/script.project @@ -237,21 +237,28 @@ System,EndLocal // =============================================================================================================================== [NukeProject] Echo,"Nuke Project Files..." -Echo,"Cleaning up files from the previous build..." -DirDeleteEx,%TargetDir% -DirDeleteEx,%ProjectTemp% -Echo,"Purging the project cache..." -DirDeleteEx,%ProjectCache% -DirDeleteEx,%ProgramsCache% +If,QUESTION,"Nuke PhoenixPE#$x#$xThis operation will obliterate all Target, ISO, Temp, Downloaded, and Cached files and return PhoenixPE to a clean build environment.#$x#$x Are you sure you want to continue?",Begin -Echo,"Removing downloaded tools..." -DirDeleteEx,%Tools%\x86\Oscdimg -DirDeleteEx,%Tools%\x64\Oscdimg + Echo,"Cleaning up files from the previous build..." + DirDeleteEx,%TargetDir% + DirDeleteEx,%ProjectTemp% -Echo,"Clearing the Output directories..." -DirDeleteEx,%ISODir% -DirDeleteEx,%OutputDir% + Echo,"Purging the project cache..." + DirDeleteEx,%ProjectCache% + DirDeleteEx,%ProgramsCache% + + Echo,"Removing downloaded tools..." + DirDeleteEx,%Tools%\x86\Oscdimg + DirDeleteEx,%Tools%\x64\Oscdimg + + Echo,"Clearing the Output directories..." + DirDeleteEx,%ISODir% + DirDeleteEx,%OutputDir% + + Echo,"Environment cleanup complete." + If,QUESTION,"Would you like to reset Source Config to defaults? (Recommended)",Exec,"%ProjectDir%\100-ConfigSource.script","SetDefaultOptions" +End [#SwitchToMainInterface#] // =============================================================================================================================== @@ -315,7 +322,7 @@ System,RefreshInterface // =============================================================================================================================== [Interface] lbl_Welcome=Welcome!,1,1,5,10,200,25,16,Bold -btn_Nuke=,1,8,288,5,25,25,NukeProject,Toxic.png,False,"__Obliterate all Target, ISO, Temp, Downloaded, and Cached Files.#$xUse this if you want to reset to a clean build environment.#$x#$xThe following folders and any files they contain will be destroyed:#$x - %TargetDir%#$x - %ISODir%#$x - %OutputDir%#$x - %ProjectCache%#$x - %ProgramsCache%#$x - Downloaded Tools (BCDEdit/DISM/Oscdimg)" +btn_Nuke=,1,8,288,5,25,25,NukeProject,Toxic.png,False,"__Obliterate all Target, ISO, Temp, Downloaded, and Cached files.#$xUse this if you want to reset to a clean build environment.#$x#$xThe following folders and any files they contain will be destroyed:#$x - %TargetDir%#$x - %ISODir%#$x - %OutputDir%#$x - %ProjectCache%#$x - %ProgramsCache%#$x - Downloaded Tools (BCDEdit/DISM/Oscdimg)" btn_Options=,1,8,320,5,25,25,SwitchToOptionsInterface,Advanced_16.png,True,"__Project Options" btn_About=,1,8,352,5,25,25,SwitchToAboutInterface,Help_16.png,True,"__About PhoenixPE" rtf_BuildInstructions=HowToBuild.rtf,1,6,5,50,373,375