PE Builder v3 plugin

PESetEnv - Set Environment Variables

Version 1.0

PESetEnv helps manage environment variables in BartPE, particularly the PATH variable.

The first problem PESetEnv solves, is when two or more plugins defining a PATH variable. For example, pebuilder defines the path in pebuilder.inf:

0x2, "ControlSet001\Control\Session Manager\Environment", "Path", "%SystemRoot%;%SystemRoot%\System32;%SystemDrive%\Bin"

and XPE redefines the path in xpe.inf:
0x2,"ControlSet001\Control\Session Manager\Environment","Path",\
"%SystemRoot%;%SystemRoot%\System32;%SystemDrive%\Bin;%SystemRoot%\system32\com;%SystemRoot%\system32\wbem;%SystemRoot%\system32\wbem\snmp;%SystemRoot%\PCHealth\HelpCtr\Binaries"

The result is the last plugin alphabetically, that defines the path, wins.

PESetEnv solves this by allowing plugins to define any paths they need added to the path, in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\PESetEnv\Path\Postfix. Then when BartPE starts, PESetEnv.exe iterates through this key, and appends each application's path to the master PATH variable.

For example, cygwin.inf file contains

[Software.AddReg]
0x1,"PESetEnv\Path\Postfix","100_cygwin","%SystemDrive%\Programs\Cygwin\bin"
0x1,"PESetEnv\Path\Postfix","101_cygwin","%SystemDrive%\Programs\Cygwin\usr\sbin"

Depending on which shell you are using, you may need to edit z_pesetenv.inf to work in your environment. If you are using XPE, uncomment the following:
0x1,"Setup","CmdLine","PESetEnv.exe XPELogon.exe -r"

If you are using nu2menu, comment out the above, and uncomment the following:
;0x1, "Setup", "CmdLine", "PESetEnv.exe \Programs\Nu2Menu\nu2menu.exe"

I will petition Bart and Gianluigi (Sherypa) to add this logic to nu2menu.exe and XPELogon.exe, which would minimize the need for a separate .exe to accomplish this task.