From 8132b87500dc8f4412b2ca36046e32c3014eebd0 Mon Sep 17 00:00:00 2001 From: Homes32 Date: Wed, 19 Feb 2025 21:36:46 -0600 Subject: [PATCH] Add sample config files in PreShellConfig docs --- PowerUsers/PreShellConfig.md | 141 ++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) diff --git a/PowerUsers/PreShellConfig.md b/PowerUsers/PreShellConfig.md index 3871089..e66cd1e 100644 --- a/PowerUsers/PreShellConfig.md +++ b/PowerUsers/PreShellConfig.md @@ -43,9 +43,148 @@ By placing a specifically named script in a pre-defined location these scripts w | PhoenixPE-UserConfig.wcz | `%TargetDir%\System32` | Compressed/Encrypted PECMD script packed in boot.wim. | | PhoenixPE-UserConfig.wcz | `%OutputDir%\PhoenixPE` | Compressed/Encrypted PECMD script included on boot media (CD/USB). | +#### Sample Config files + +**Autoit3 Script using PhoenixPE extensions** + +``` +#NoTrayIcon +; This is a user defined PhoenixPE configuration file. +; It will be executed during the PhoenixPE Pre-Shell config. + +AutoItSetOption("ExpandEnvStrings", 1) + +; Main +Config() +Shortcuts() +LoadDrivers() +RunPrograms() + +Func Config() + SetSplashText("Additional configuration in progress...") + RegWrite("HKEY_LOCAL_MACHINE\Software\Example", "Key1", "REG_SZ", "This is an example of RegWrite") +EndFunc ;==>Config + +Func Shortcuts() + SetSplashText("Creating additional shortcuts...") + MakeShortcut("%WinDir%\myProgram.exe", @ProgramsCommonDir & "\MyProgram.lnk") +EndFunc ;==>Shortcuts + +Func LoadDrivers() + SetSplashText("Loading additional drivers...") + RunProgramWait(@SystemDir & "\Drvload.exe %WinDir%\inf\basicdisplay.inf", "", @SW_HIDE) + RunProgram(@SystemDir & "\pnputil.exe", "/add-driver %WinDir%\inf\hdaudio.inf /install", "", @SW_HIDE) +EndFunc ;==>LoadDrivers + +Func RunPrograms() + SetSplashText("Running additional programs...") + RunProgramWait("Y:\Autorun.cmd", "", "", @SW_HIDE) + RunProgram("Y:\Programs\Sysinternals\procmon.exe") +EndFunc ;==>RunPrograms +``` + +**Autoit3 Script using pure Autoit functions** + +``` +#NoTrayIcon +; This is a user defined PhoenixPE configuration file. +; It will be executed during the PhoenixPE Pre-Shell config. + +AutoItSetOption("ExpandEnvStrings", 1) + +; Main +Config() +Shortcuts() +LoadDrivers() +RunPrograms() +SplashOff() + +Func Config() + SplashTextOn("", "Additional configuration in progress...", 500, 50, -1, 600, 1) + RegWrite("HKEY_LOCAL_MACHINE\Software\Example", "Key1", "REG_SZ", "This is an example of RegWrite") +EndFunc ;==>Config + +Func Shortcuts() + SplashTextOn("", "Creating additional shortcuts...", 500, 50, -1, 600, 1) + FileCreateShortcut("%WinDir%\myProgram.exe", @ProgramsCommonDir & "\MyProgram.lnk") +EndFunc ;==>Shortcuts + +Func LoadDrivers() + SplashTextOn("", "Loading additional drivers...", 500, 50, -1, 600, 1) + RunWait(@SystemDir & "\Drvload.exe %WinDir%\inf\basicdisplay.inf", @SW_HIDE) + Run(@SystemDir & "\pnputil.exe", "/add-driver %WinDir%\inf\hdaudio.inf /install", "", @SW_HIDE) +EndFunc ;==>LoadDrivers + +Func RunPrograms() + SplashTextOn("", "Running additional programs...", 500, 50, -1, 600, 1) + RunWait("Y:\Autorun.cmd", "", @SW_HIDE) + Run("Y:\Programs\Sysinternals\procmon.exe") +EndFunc ;==>RunPrograms +``` + +**PECMD Script** + +``` +// This is a user defined PECMD configuration file. +// It will be executed during the PhoenixPE Pre-Shell config. + +CALL Config +CALL Shortcuts +CALL LoadDrivers +CALL RunPrograms +WAIT 3000 + +//////////////////////////////////////////////////////////////////////////////////////////////// +_SUB Config + +TEXT Additional configuration in progress...#0xFFFFFF L59 T39 $20 + +DISP W1024 H768 B32 F60 + +_END Config + +//////////////////////////////////////////////////////////////////////////////////////////////// +_SUB Shortcuts + +TEXT Creating additional shortcuts...#0xFFFFFF L59 T39 $20 + +LINK %Programs%\Explorer,%WinDir%\myProgram.exe + +_END Shortcuts + +//////////////////////////////////////////////////////////////////////////////////////////////// +_SUB LoadDrivers + +TEXT Loading additional drivers...#0xFFFFFF L59 T39 $20 + +DEVI %WinDir%\inf\xxxxx.inf + +_END LoadDrivers + +//////////////////////////////////////////////////////////////////////////////////////////////// +_SUB RunPrograms + +// Syntax: EXEC [WorkingDir] +// : = - Wait +// @ - Background +// ! - Hide +// Example: +// EXEC =WaitNoHide.cmd - Execute WaitNoHide.cmd and wait until it is finished before continuing +// EXEC @!=WaitHide.cmd - Execute WaitHide.cmd, hide the window and wait until it is finished before continuing. +// EXEC NoWaitNoHide.cmd - Execute NoWaitNoHide.cmd and continue with the next command. +// EXEC @!NoWaitHide.cmd - Execute NoWaitHide.cmd, hide the window and continue with the next command. + +TEXT Running additional programs...#0xFFFFFF L59 T39 $20 + +EXEC @!Y:\Autorun.cmd +EXEC Y:\Programs\Sysinternals\procmon.exe + +_END RunPrograms +``` + ### AddAutoRun -You may also choose to run AutoIt3 or PECMD scripts directly at different startup stages using the `AddAutoRun` command. +For more flexibility, you may choose to run AutoIt3 or PECMD scripts directly at different startup stages using the `AddAutoRun` command. **Example**