{"id":615,"date":"2017-01-04T05:42:00","date_gmt":"2017-01-04T13:42:00","guid":{"rendered":"https:\/\/kb.terabyteunlimited.com\/kb-articles\/adding-programs-to-tbwinpe-re-builds\/"},"modified":"2025-10-28T00:07:47","modified_gmt":"2025-10-28T07:07:47","slug":"adding-programs-to-tbwinpe-re-builds","status":"publish","type":"lsvr_kba","link":"https:\/\/www.terabyteunlimited.com\/kb\/kb-articles\/adding-programs-to-tbwinpe-re-builds\/","title":{"rendered":"Adding Programs and Scripts to TBWinPE\/RE Builds"},"content":{"rendered":"  <p>This article covers several methods to add programs, scripts, and other files to the Image for Windows TBWinPE\/RE boot media using TBWinPE\/RE Builder. <\/p>\r\n  <p>If you are unfamiliar with the process of creating the TBWinPE\/RE boot media, you may find it helpful to create a standard build before attempting a custom build. Tutorials for creating the TBWinPE\/RE boot media can be found in the following how-to articles:<\/p>\r\n  <blockquote>\r\n    <p><a href=\"http:\/\/www.terabyteunlimited.com\/howto\/tbwinre_tutorial.htm\" target=\"_blank\">Creating a TeraByte Recovery Environment, WinRE Boot Disc, or UFD Containing Image for Windows (TBWinRE)<\/a><\/p>\r\n    <p><a href=\"http:\/\/www.terabyteunlimited.com\/howto\/tbwinpe_tutorial.htm\" target=\"_blank\">Creating a TeraByte WinPE Boot Disc Containing Image for Windows (TBWinPE)<\/a><\/p>\r\n    <\/blockquote>\r\n  <p><strong>Note:<\/strong> Adding programs and files can also be done using  the TBWinPE.cmd and TBWinRE.cmd scripts. However, those scripts are now obsolete and TBWinPE\/RE Builder should be used instead.<\/p>\r\n  <p>&nbsp;<\/p>\r\n<p><font color=\"#005858\"><strong>Requirements &amp; Considerations<\/strong><\/font><\/p>\r\n<ul>\r\n  <li>The program being added must run in the standard WinPE\/RE environment, which is very limited compared to normal Windows. Many programs many not run at all or have missing\/broken features due to lack of support. If you are unsure if the program you wish to add will run in WinPE\/RE you can try it using Method 1 (below) before creating a custom build that includes it.<br \/>\r\n    <br \/>\r\n  <\/li>\r\n  <li>The program must be the correct architecture for the build. If creating a 64-bit (x64) build, the program being added must be 64-bit. If creating a 32-bit (x86) build, the program being added must be 32-bit. Some programs may only be available as 32-bit versions and since almost all current Windows installations are 64-bit this means that most TBWinRE builds would also be 64-bit. In this case, if you require a 32-bit (x86) build you will need to create a TBWinPE build using an older Windows 10 ADK.<br \/>\r\n    <br \/>\r\n  <\/li>\r\n    <li>When adding scripts, the normal types are CMD and TBS (assuming TBOSDT Pro is also included in the build). Other types of scripts may not be supported in the WinPE\/RE environment. For example, you might include a backup-win11.cmd script which runs Image for Windows and backs up your Windows 11 installation.<br>\r\n      <br>\r\n    <\/li>\r\n    <li>In the methods below, a USB flash drive (UFD) is used for the boot media as it offers more flexibility than read-only media (e.g., CD\/DVD). Rewritable media, such as a UFD, is recommended when first creating, configuring, and testing the build even if it will eventually be put on read-only media when finalized.<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>TBWinRE files are automatically installed with Image for Windows on Windows 7 or later. However, when creating a customized build, you may find copying the files to an alternate folder with standard user-level permissions will make the process easier. If creating multiple custom builds it may be beneficial to place each one in a separate folder. Using an alternate folder also gives you control over when the build files are updated since updating Image for Windows won't replace them. In the examples below, the TBWinRE files are located in C:&#92;TBWinRE.<br>\r\n      <br>\r\n    <\/li>\r\n    <li>While both plugins and the BuildScript option can be used to include programs, scripts, and other files, using a plugin provides more features, options, and flexiblity than BuildScript. Creating a plugin is a simple process and usually only requires a few lines of code to include a simple program or script. In addition to the example shown in this article, you can refer to the following for more information on using plugins:<br>\r\n      <a href=\"https:\/\/www.terabyteunlimited.com\/howto\/builder_settings\/#Plugins\">TBWinPE\/RE Builder Settings | Plugins<\/a><br>\r\n      <a href=\"https:\/\/www.terabyteunlimited.com\/downloads\/tbplg_manual_en.pdf\">Plugins Manual (PDF)<\/a><br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>The methods shown in this article are basic examples -- custom builds are not limited to these particular scenarios.<\/li>\r\n  <\/ul>\r\n  <p>&nbsp;<\/p>\r\n  <p><font color=\"#005858\"><strong>Contents<\/strong><\/font><\/p>\r\n  <blockquote>\r\n    <p><a href=\"#method1\">Method 1 - Standard Build with Program on UFD<\/a><\/p>\r\n    <p><a href=\"#method2\">Method 2 - Custom Build with Program on UFD (using BuildScript)<\/a><\/p>\r\n    <p><a href=\"#method3\">Method 3 - Custom Build with Program Included in Build (using BuildScript)<\/a><\/p>\r\n    <p><a href=\"#method4\">Method 4 - Custom Build with Program Included in Build (using a Plugin)<\/a><\/p>\r\n    <p><a href=\"#appendix\">Appendix<\/a><\/p>\r\n    <p>&nbsp;<\/p>\r\n  <\/blockquote>\r\n  <p id=\"method1\"><span style=\"color: #005858; background-color:#DDD; border-radius:10px; padding:5px 10px;\"><font color=\"#005858\"><strong>Method 1 - Standard Build with Program on UFD<\/strong><\/font><\/span><\/p>\r\n  <p>This method provides an easy way to manually add a program to the boot media.\r\n  <\/p><ol>\r\n    <li>Create the TBWinPE\/RE build normally and save it to a UFD.<\/li>\r\n    <li>Create a folder on the UFD to hold the program files.<\/li>\r\n    <li>Copy the program files into the folder.<\/li>\r\n    <li>Boot to the UFD.<\/li>\r\n    <li>Browse to the program on the UFD and run it. This can be done directly from TBLauncher (<em>File<\/em> | <em>Run<\/em>) or you can open a Command Prompt and run it from there.<\/li>\r\n  <\/ol>\r\n  <p>Alternatively, when just testing if the program will run from TBWinPE\/RE you could skip copying the program files to the UFD and instead run the program directly from a local drive (e.g., a folder on your Windows partition or data partition). <\/p>\r\n  <p><strong>Note:<\/strong> When using this method any files copied to the UFD will be lost when the UFD is updated to a new build using MakeDisk. To avoid this, update the UFD using TBWinPE\/RE Builder or by manually by copying the contents of the new build's ISO folder to the root folder of the UFD (replacing existing files) instead of running MakeDisk. Refer to the following KB article for more details: <a href=\"https:\/\/www.terabyteunlimited.com\/kb\/article.php?id=620\" target=\"_blank\">Manually Updating the TBWinPE\/RE Boot Media<\/a><\/p>\r\n  <p>&nbsp;<\/p>\r\n  <p id=\"method2\"><span style=\"color: #005858; background-color:#DDD; border-radius:10px; padding:5px 10px;\"><font color=\"#005858\"><strong>Method 2 - Custom Build with Program on UFD (using BuildScript)<\/strong><\/font><\/span><\/p>\r\n  <p>This method is similar to Method 1, but with several enhancements:\r\n  <\/p><ul>\r\n    <li>Program is added to TBLauncher's menu, which can optionally be tweaked\/configured without recreating the build.<\/li>\r\n    <li>Program files can be updated simply by copying the files to the UFD (recreating the build isn't necessary).<\/li>\r\n    <li>Program files can optionally be updated automatically when a new build is created.<\/li>\r\n  <\/ul>\r\n  <p>Instructions:\r\n  <\/p><ol>\r\n    <li>Copy the files for the program being added to a sub-folder in the <font color=\"#0000ff\">ISO<\/font> folder of the TBWinRE folder. The ISO folder won't exist if a build hasn't previously been created. If necessary, create the ISO folder before creating the folder for the program. <font color=\"#0000ff\">C:&#92;TBWinRE&#92;ISO&#92;CustomProg<\/font> is used here with the program consisting of <font color=\"#0000ff\">program.exe<\/font> and supporting files.<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>Add the program to the TBLauncher menu: <br \/>\r\n      <br \/>\r\n<ol type=\"a\">\r\n  <li>Run TBWinPE\/RE Builder and go into <strong>Settings<\/strong>. Select the <strong>TBLauncher<\/strong> tab. Click the <strong>Edit TBLauncher.ini<\/strong> link at the bottom of the window. This will open the file in Notepad.<br \/>\r\n    <br \/>\r\n  <\/li>\r\n        <li>Scroll through the file and locate the <font color=\"#0000ff\">[Menu]<\/font> section. A new menu entry will be added so increment the <font color=\"#0000ff\">ItemCount<\/font> value. In this example, there are already 10 menu items so the new one will be 11.<br \/>\r\n          <br \/>\r\n          <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>[Menu]\r\n          ItemCount=11<\/strong><\/font><br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>Scroll to the end of the file and add the menu entry for the program being added.<br \/>\r\n          <p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>[Menu_Item_11]\r\n            Name=Custom Program<br \/>\r\n            Path=%TBDrive%&#92;CustomProg&#92;program.exe<br \/>\r\n            WorkingDir=<br \/>\r\n            Parameters=<br \/>\r\n            Icon=0<\/strong><\/font><br \/>\r\n            <br \/>\r\n            Keeping the program name short is recommended due to limited space in the menu. If the program requires a working directory or parameters you can set those as well.\r\n            <br \/>\r\n            <br \/>\r\n            By default, the icon is retrieved from the program file. With TBLauncher 1.15+ you can use a custom icon by specifying the path to the file (supported file types: .ico, .exe, .dll). If the icon file is not found or there is an error the icon from the program will be used. For example: <br \/>\r\n            <br \/>\r\n            <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>Icon=0,%TBDrive%&#92;CustomProg&#92;program.ico<\/strong><\/font> <br \/>\r\n            <br \/>\r\n            <strong>Note:<\/strong> The icon index value is specified (0, above), but is not applicable to .ico files. <\/p>\r\n        <\/li>\r\n        <li>Save TBLauncher.ini and close Notepad.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>Enable the <strong>Search for TBWinRE\/PE boot media drive after booting<\/strong> option. This will locate the UFD once it's booted and set the <strong>%TBDrive%<\/strong> environment variable used for the menu item.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>Click <strong>OK<\/strong> to close Settings.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <\/ol>\r\n    <\/li>\r\n    <li><strong><em>[Optional]<\/em><\/strong> Copy the TBLauncher.ini file from the build's <font color=\"#0000ff\">config<\/font> folder to the <font color=\"#0000ff\">ISO&#92;TBData<\/font> folder. This allows changes to the menu items (descriptions, paths, etc.) to be made  by editing the file in the boot media's TBData folder (no need to recreate the build). In this example, you would copy <font color=\"#0000ff\">C:&#92;TBWinRE&#92;config&#92;TBLauncher.ini<\/font> to <font color=\"#0000ff\">C:&#92;TBWinRE&#92;ISO&#92;TBData<\/font>. Keep in mind that if you edit the original file you will also need to update the copy (this could be scripted if you want it to happen automatically). If changes are made to the file on the boot media and you don't want them lost when recreating the media, copy the modified file to the build's ISO&#92;TBData folder.<br \/>\r\n      <br \/>\r\n      <strong>Note:<\/strong> The TBLauncher<strong> Search for TBWinRE\/PE boot media drive after booting<\/strong> option must be enabled in the build for this feature to function (see Step 2e). For boot media that has already been created with this option enabled, the feature can be used by simply copying the TBLauncher.ini file to the TBData folder on the boot media.<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li><strong><em>[Optional]<\/em><\/strong> Configure the BuildScript to copy the program files to the <font color=\"#0000ff\">ISO&#92;CustomProg<\/font> folder. This allows the files to automatically be copied into the build each time it's created. For example, if the program files have been updated in the source location the build would include those updated files.<br \/>\r\n      <br \/>\r\n<ol type=\"a\">\r\n  <li>Open <strong>Settings<\/strong>. Select the <strong>Scripts<\/strong> tab.<br \/>\r\n    <br \/>\r\n  <\/li>\r\n        <li>Enable the <strong>Use BuildScript.cmd<\/strong> option.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>Click the <strong>Edit<\/strong> link next to the BuildScript option. If the script file doesn't already exist you will be prompted to create it. The script will open in Notepad for editing. Add the commands necessary to copy the program files from their source location to the <font color=\"#0000ff\">ISO&#92;CustomProg<\/font> folder. In this example, the source folder is <font color=\"#0000ff\">F:&#92;CustomProgSource<\/font>. The script will first create the sub-folder in the ISO folder (in case it doesn't exist) and then copy all the files from the source folder to the new program folder.<br \/>\r\n          <br \/>\r\n          <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>:: Add script commands after this line<br \/>\r\n          md &quot;%TBWinPE_BuildPath%&#92;ISO&#92;CustomProg&quot; 2&gt; nul<br \/>\r\n            copy &quot;F:&#92;CustomProgSource&#92;*.*&quot; &quot;%TBWinPE_BuildPath%&#92;ISO&#92;CustomProg&quot;<\/strong><\/font>          <br \/>\r\n            <br \/>\r\n        <\/li>\r\n        <li>If configuring Step 3, you could have the script automatically copy the TBLauncher.ini file from the build's config folder to the ISO&#92;TBData folder.<br \/>\r\n          <br \/>\r\n          <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>:: Copy TBLauncher.ini to TBData<br \/>\r\n          copy &quot;%TBWinPE_ConfigPath%&#92;TBLauncher.ini&quot; &quot;%TBWinPE_BuildPath%&#92;ISO&#92;TBData&quot;<\/strong><\/font><br \/>\r\n        <br \/>\r\n        <\/li>\r\n        <li>Save BuildScript.cmd and close Notepad.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>Click <strong>OK<\/strong> to close Settings.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n      <\/ol>\r\n    <\/li>\r\n    <li>Finish creating the build normally and use MakeDisk to create the boot media on a UFD.<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>Boot the  UFD and verify the custom program shows up in the TBLauncher menu and runs properly. If any tweaks\/corrections are required, edit the relevant files on the UFD and reboot to test. When finalized, update the affected build files with the revised versions so the next build will use them.<\/li>\r\n  <\/ol>\r\n  <p>&nbsp;<\/p>\r\n  <p id=\"method3\"><span style=\"color: #005858; background-color:#DDD; border-radius:10px; padding:5px 10px;\"><font color=\"#005858\"><strong>Method 3 - Custom Build with Program Included in Build (using BuildScript)<\/strong><\/font><\/span><\/p>\r\n  <p>This method is similar to Method 2, but with several major differences:\r\n  <\/p><ul>\r\n    <li>Program is added to TBLauncher's menu, but modifying the menu requires recreating the build.<\/li>\r\n    <li>Program is included in the build (packed in the WIM file) and will exist on the WinPE RAM disk (drive X:) when booted.<\/li>\r\n    <li>Updating Program files requires recreating the build.<\/li>\r\n  <\/ul>\r\n  <p>Instructions:\r\n  <\/p><ol>\r\n    <li>Make note of the folder containing the program files that will be added to the build. <font color=\"#0000ff\">F:&#92;CustomProgSource<\/font> is used here with the program consisting of <font color=\"#0000ff\">program.exe<\/font> and supporting files.<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>Add the program to the TBLauncher menu: <br \/>\r\n      <br \/>\r\n<ol type=\"a\">\r\n  <li>Run TBWinPE\/RE Builder and go into <strong>Settings<\/strong>. Select the <strong>TBLauncher<\/strong> tab. Click the <strong>Edit TBLauncher.ini<\/strong> link at the bottom of the window. This will open the file in Notepad.<br \/>\r\n    <br \/>\r\n  <\/li>\r\n        <li>Scroll through the file and locate the <font color=\"#0000ff\">[Menu]<\/font> section. A new menu entry will be added so increment the <font color=\"#0000ff\">ItemCount<\/font> value. In this example, there are already 10 menu items so the new one will be 11.<br \/>\r\n          <br \/>\r\n          <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>[Menu]\r\n          ItemCount=11<\/strong><\/font><br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>Scroll to the end of the file and add the menu entry for the program being added.<br \/>\r\n          <p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>[Menu_Item_11]\r\n            Name=Custom Program<br \/>\r\n            Path=%ProgramFiles%&#92;CustomProg&#92;program.exe<br \/>\r\n            WorkingDir=<br \/>\r\n            Parameters=<br \/>\r\n            Icon=0<\/strong><\/font><br \/>\r\n            <br \/>\r\n            Keeping the program name short is recommended due to limited space in the menu. If the program requires a working directory or parameters you can set those as well.\r\n            <br \/>\r\n            <br \/>\r\n            Since the drive letter of the booted RAM drive is known (X:) you could specify it instead of the %ProgramFiles% environment variable. For example:<br \/>\r\n            <br \/>\r\n            <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>Path=X:&#92;Program Files&#92;CustomProg&#92;program.exe<\/strong><\/font>\r\n            <br \/>\r\n            <br \/>\r\n            By default, the icon is retrieved from the program file. With TBLauncher 1.15+ you can use a custom icon by specifying the path to the file (supported file types: .ico, .exe, .dll). If the icon file is not found or there is an error the icon from the program will be used. For example: <br \/>\r\n            <br \/>\r\n            <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>Icon=0,%ProgramFiles%&#92;CustomProg&#92;custom.ico<\/strong><\/font> <br \/>\r\n            <br \/>\r\n            <strong>Note:<\/strong> The icon index value is specified (0, above), but is not applicable to .ico files.\r\n          <\/p>\r\n        <\/li>\r\n        <li>Save TBLauncher.ini and close Notepad.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <\/ol>\r\n    <\/li>\r\n    <li>Configure the BuildScript to copy the program files to the <font color=\"#0000ff\">mount&#92;Program Files&#92;CustomProg<\/font> folder.<br \/>\r\n      <br \/>\r\n<ol type=\"a\">\r\n  <li>While still in <strong>Settings<\/strong>, select the <strong>Scripts<\/strong> tab.<br \/>\r\n    <br \/>\r\n  <\/li>\r\n        <li>Enable the <strong>Use BuildScript.cmd<\/strong> option.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>Click the <strong>Edit<\/strong> link next to the BuildScript option. If the script file doesn't already exist you will be prompted to create it. The script will open in Notepad for editing. Add the commands necessary to copy the program files from their source location to the <font color=\"#0000ff\">mount&#92;Program Files&#92;CustomProg<\/font> folder. In this example, the source folder is <font color=\"#0000ff\">F:&#92;CustomProgSource<\/font>. The script will first create the <font color=\"#0000ff\">CustomProg<\/font> sub-folder and then copy all the files from the source folder to the new program folder.<br \/>\r\n          <br \/>\r\n          <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>:: Add script commands after this line<br \/>\r\n          md &quot;%TBWinPE_MountPath%&#92;Program Files&#92;CustomProg&quot; 2&gt; nul<br \/>\r\n            copy &quot;F:&#92;CustomProgSource&#92;*.*&quot; &quot;%TBWinPE_MountPath%&#92;Program Files&#92;CustomProg&quot;<\/strong><\/font>          <br \/>\r\n            <br \/>\r\n        <\/li>\r\n        <li>Save BuildScript.cmd and close Notepad.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>Click <strong>OK<\/strong> to close Settings.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n      <\/ol>\r\n    <\/li>\r\n    <li>Finish creating the build normally and use MakeDisk to create the boot media on a UFD.<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>Boot the  UFD and verify the custom program shows up in the TBLauncher menu and runs properly. If any tweaks\/corrections are required, edit the relevant files and recreate the build and boot media.<\/li>\r\n  <\/ol>\r\n  <p>&nbsp;<\/p>\r\n  <p id=\"method4\"><span style=\"color: #005858; background-color:#DDD; border-radius:10px; padding:5px 10px;\"><font color=\"#005858\"><strong>Method 4 - Custom Build with Program Included in Build (using a Plugin)<\/strong><\/font><\/span><\/p>\r\n  <p>This method is similar to Method 3, but uses a plugin to add the program to the build.<\/p>\r\n  <p>Instructions: <\/p>\r\n  <ol>\r\n    <li>Make note of the folder containing the program files that will be added to the build. <font color=\"#0000ff\">F:&#92;CustomProgSource<\/font> is used here with the program consisting of <font color=\"#0000ff\">program.exe<\/font> and supporting files.<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>Create new plugin for adding the program: <br \/>\r\n      <br \/>\r\n      <ol type=\"a\">\r\n        <li>Run TBWinPE\/RE Builder and go into <strong>Settings<\/strong>. Select the <strong>Plugins<\/strong> tab. More information on the Plugins tab can be found in the <a href=\"https:\/\/www.terabyteunlimited.com\/howto\/builder_settings\/#Plugins\">tutorial<\/a>.<br>\r\n          <br>\r\n        <\/li>\r\n        <li> Click the <strong>Create plugin<\/strong> button. This will open the Create Plugin dialog.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>In the Details section, fill in the Plugin Name, Author, and Description fields as desired.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n        <li>In the Plugin File field, enter the filename for the plugin (e.g., addprog) or click the <strong>Browse...<\/strong> button and create a new sub-folder for the plugin. By default, new plugins will be saved in the build's Plugins folder. However, if the plugin will consist of multiple files, having it in its own sub-folder is recommended.<br>\r\n          <br>\r\n        <\/li>\r\n        <li>In the Support Options section, enable the desired build modes, build types, and architectures that will be supported. At the very least, make sure the ones you need for your particular build are enabled. These settings can always be changed later by editing the plugin file.<br>\r\n          <br>\r\n        <\/li>\r\n        <li>Click the <strong>Create<\/strong> button to create the plugin and return to the Plugins tab.<br \/>\r\n          <br \/>\r\n        <\/li>\r\n      <\/ol>\r\n    <\/li>\r\n    <li>Back on the <strong>Plugins<\/strong> tab, select (highlight) the new plugin in the list and then click the <strong>Edit plugin<\/strong> button. The plugin file will open in Notepad.<br>\r\n      <br>\r\n    <\/li>\r\n    <li>Add the code to the plugin that will add your program:<br \/>\r\n      <br \/>\r\n      <ol type=\"a\">\r\n        <li>Scroll to the <strong>[Code]<\/strong> section and the <strong>sub Process<\/strong> line (this is at the end of the file). The new code will be placed in the <strong>Process<\/strong> subroutine (between the <strong>sub Process<\/strong> and <strong>end sub<\/strong> lines).<br \/>\r\n          <br \/>\r\n          <\/li>\r\n        <li>Edit the subroutine code to be as shown below, adjusting the folders and filenames to be correct for the program being added. Lines that start with <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>\/\/<\/strong><\/font> are comments.<br \/>\r\n          <br \/>\r\n          <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>sub Process<br>\r\n          &nbsp;&nbsp;&nbsp;log &quot;Adding Custom Program to build...&quot;<br>\r\n          &nbsp;&nbsp;&nbsp;\/\/ create folder for program files\r\n          <br \/>\r\n            &nbsp;&nbsp;&nbsp;FolderCreate &quot;@tbMountPath@&#92;Program Files&#92;CustomProg&quot;<br>\r\n            &nbsp;&nbsp;&nbsp;\/\/ copy program files from source location\r\n            <br \/>\r\n            &nbsp;&nbsp;&nbsp;FileCopy &quot;F:&#92;CustomProgSource&#92;*.*&quot; &quot;@tbMountPath@&#92;Program Files&#92;CustomProg&quot;<br>\r\n            &nbsp;&nbsp;&nbsp;\/\/ add program to TBLauncher's menu<br>\r\n            &nbsp;&nbsp;&nbsp;MenuItem &quot;Custom Program&quot; &quot;X:&#92;Program Files&#92;CustomProg&#92;program.exe&quot;<br>\r\n            end sub\r\n          <\/strong><\/font> <br>\r\n          <br>\r\n          <strong>Note:<\/strong> The <strong><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>FolderCopy<\/strong><\/font> <\/strong>command could also be used to copy the program's folder and sub-folders into the build. This example simply copies all the files from the specified folder.<br \/>\r\n          <br \/>\r\n          <\/li>\r\n        <li>When the changes are complete, save the file and close Notepad.<br \/>\r\n          <br \/>\r\n          <\/li>\r\n      <\/ol>\r\n    <\/li>\r\n    <li>In General Options, enable the <strong>Include plugins in build<\/strong> option. If using Developer Mode to test the plugin, also enable the <strong>Enable Developer Mode (DevMode)<\/strong> option.<br>\r\n      <br>\r\n    <\/li>\r\n    <li>In the plugins list, enable your new plugin.<br>\r\n      <br>\r\n    <\/li>\r\n    <li>Click <strong>OK<\/strong> to save and close Settings.<br>\r\n      <br>\r\n    <\/li>\r\n    <li>Finish creating the build normally and use MakeDisk to create the boot media on a UFD.<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>Boot the  UFD and verify the custom program shows up in the TBLauncher menu and runs properly. If any tweaks\/corrections are required, edit the relevant files and recreate the build and boot media.<\/li>\r\n  <\/ol>\r\n  <p>The plugin example above covers the basics. Additional code could be added to do error checking, set up configuration options (such as the source path), and much more.<\/p>\r\n  <p>&nbsp;<\/p>\r\n  <hr \/><hr \/>\r\n  <p id=\"appendix\"><strong><font color=\"#ff5500\">Appendix<\/font><\/strong><\/p>\r\n  <p><font color=\"#005858\"><strong>Custom Build Tips<\/strong><\/font><\/p>\r\n  <ul>\r\n    <li>You can change the order of the items shown in the TBLauncher menu by changing the item number for the entry. For example, if you want your custom program to be the first menu item, use Menu_Item_1 for its section and renumber the other items (Image for Windows becomes Menu_Item_2, etc.).<br \/>\r\n      <br \/>\r\n    <\/li>\r\n    <li>Use the<strong> Pause build before unmounting WIM file<\/strong> option (on <em>Build Options<\/em> tab in <em>Settings<\/em>) to verify the changes are correct in the build before it's unmounted. If necessary, you can tweak things before continuing. If browsing or working in the <font color=\"#0000ff\">mount<\/font> folder be sure to browse out of it, etc. before continuing so Windows doesn't prevent the unmount from succeeding.<br>\r\n      <br>\r\n    <\/li>\r\n    <li>When using a plugin, enable <strong>Developer Mode<\/strong> to allow pausing the build after the plugin runs so it can be edited, tested, and rerun, if necessary. Refer to the <a href=\"https:\/\/www.terabyteunlimited.com\/downloads\/tbplg_manual_en.pdf\">Plugins Manual (PDF)<\/a> for details on using Developer Mode.<br>\r\n      <br>\r\n    <\/li>\r\n    <li>Several example plugins are available for download on the Plugins tab. These, and the other plugins, can be examined to see how programs and files can be added to builds.<br \/>\r\n    <\/li>\r\n  <\/ul>\r\n  <p><strong><font color=\"#005858\">Using Build Variables (Plugins)<\/font><\/strong><\/p>\r\n  <blockquote>\r\n    <p>TBWinPE\/RE Builder provides many built-in variables for use in plugins. Several are listed below:<\/p>\r\n    <p><strong>tbArch<\/strong>: The architecture of the build being created (<strong>x86<\/strong>, <strong>AMD64, ARM64<\/strong>).<br \/>\r\n      <strong>tbx64<\/strong>: Will be <strong>64<\/strong> if creating a 64-bit build. Empty string for 32-bit.<br \/>\r\n      <strong>tbBuildPath<\/strong>: Complete path to project folder.<br \/>\r\n      <strong>tbConfigPath<\/strong>: Complete path to project's <font color=\"#0000ff\">config<\/font> folder.<br \/>\r\n      <strong>tbMountPath<\/strong>: Complete path to project's <font color=\"#0000ff\">mount<\/font> folder.<br>\r\n      <strong>tbPluginPath<\/strong>: Complete path to plugin's folder. <br \/>\r\n      <strong>tbMode<\/strong>: Build mode (<strong>TBWinPE<\/strong>, <strong>TBWinRE<\/strong>).<br>\r\n      <strong>tbRegDefault<\/strong>:  Default user registry hive mount path.<br>\r\n      <strong>tbRegSoftware<\/strong>: Software registry hive mount path.<br>\r\n      <strong>tbRegSystem<\/strong>: System registry hive mount path.<\/p>\r\n<\/blockquote>\r\n  <p><strong><font color=\"#005858\">Using Build Environment Variables (BuildScript)<\/font><\/strong><\/p>\r\n  <blockquote>\r\n    <p>TBWinPE\/RE Builder assigns several environment variables for use in BuildScript.cmd:<\/p>\r\n    <p><strong>TBWinPE_Arch<\/strong>: The architecture of the build being created (<strong>x86<\/strong>, <strong>AMD64<\/strong>).<br \/>\r\n      <strong>TBWinPE_x64<\/strong>: Will be assigned <strong>64<\/strong> if creating a 64-bit build. Unassigned for 32-bit.<br \/>\r\n      <strong>TBWinPE_BuildPath<\/strong>: Complete path to project folder.<br \/>\r\n      <strong>TBWinPE_ConfigPath<\/strong>: Complete path to project's <font color=\"#0000ff\">config<\/font> folder.<br \/>\r\n      <strong>TBWinPE_MountPath<\/strong>: Complete path to project's <font color=\"#0000ff\">mount<\/font> folder.<br \/>\r\n      <strong>TBWinPE_Mode<\/strong>: Build mode (<strong>TBWinPE<\/strong>, <strong>TBWinRE<\/strong>).<br>\r\n      <strong>TBWINPE_Reg_DEFAULT<\/strong>:  Default user registry hive mount path.<br>\r\n      <strong>TBWINPE_Reg_SOFTWARE<\/strong>: Software registry hive mount path.<br>\r\n      <strong>TBWINPE_Reg_SYSTEM<\/strong>: System registry hive mount path.<\/p>\r\n    <p>If necessary, you can check which environment variables are available and their assigned values by creating a simple BuildScript.cmd that runs the <em>set<\/em> and <em>pause<\/em> commands to display them. When you create the build it will list all environment variables and values and wait for a keypress to continue. For example:<\/p>\r\n    <p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>:: Add script commands after this line<br \/>\r\n          set<br \/>\r\n          pause<\/strong><\/font><\/p>\r\n  <\/blockquote>\r\n  <p><font color=\"#005858\"><strong>Adding\/Editing Registry Settings (Plugins)<\/strong><\/font><\/p>\r\n  <blockquote>\r\n    <p>You can easily add or change registry settings for the build by using the plugin registry commands.<\/p>\r\n    <p>The registry hives are loaded under HKEY_LOCAL_MACHINE and the paths are available in the following variables:<\/p>\r\n    <p><strong>tbRegSystem<\/strong>: System hive<br \/>\r\n      <strong>tbRegSoftware<\/strong>: Software hive<br \/>\r\n      <strong>tbRegDefault<\/strong>: Default user hive <\/p>\r\n    <p>Example command adding an environment variable to the SYSTEM hive. Command should all be on one line:<\/p>\r\n<p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>RegSetValue &quot;@tbRegSystem@&#92;ControlSet001&#92;Control&#92;Session  Manager&#92;Environment&quot; &quot;MyEnvVar&quot; &quot;ABC&quot;<\/strong><\/font><\/p>\r\n<p>Example commands adding several custom program variables to the SOFTWARE hive. Each command should be on one line:<\/p>\r\n<p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>RegSetValue \/c &quot;@tbRegSoftware@&#92;CustomProgram&quot; &quot;Title&quot; &quot;WinPE Custom Program&quot;<\/strong><\/font><\/p>\r\n    <p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>RegSetValue &quot;@tbRegSoftware@&#92;CustomProgram&quot; &quot;Cache Size&quot; RegDWORD(1024)<\/strong><\/font><\/p>\r\n    <p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>RegSetValue &quot;@tbRegSoftware@&#92;CustomProgram&quot; &quot;Default Path&quot; &quot;X:&#92;Custom Files&quot;<\/strong><\/font><\/p>\r\n    <p>For more details and examples, refer to the <a href=\"https:\/\/www.terabyteunlimited.com\/downloads\/tbplg_manual_en.pdf\">Plugins Manual (PDF)<\/a>.<\/p>\r\n<\/blockquote>\r\n  <p><font color=\"#005858\"><strong>Adding\/Editing Registry Settings (BuildScript)<\/strong><\/font><\/p>\r\n  <blockquote>\r\n    <p>You can add or change registry settings for the build by using the <strong>reg<\/strong> program in BuildScript.cmd. It's also possible to pause the build and manually add\/edit the mounted registry hives using Registry Editor, but care must be taken to browse out of the mounted hives or close Registry Editor before continuing with the build or errors may result due to Windows preventing the hive files from unmounting.<\/p>\r\n    <p>When using TBWinPE\/RE Builder's BuildScript, it's recommended to either use the appropriate environment variable (e.g., %TBWINPE_Reg_SOFTWARE%) or disable the <strong>Use DISM API if supported<\/strong> option (<em>General<\/em> tab in <em>Settings<\/em>) to have access to the short names for the mounted hive files.<\/p>\r\n    <p>The registry hives are loaded under HKEY_LOCAL_MACHINE (names shown here are when the DISM API is not used):<\/p>\r\n    <p><strong>TBWINPE_SYSTEM<\/strong>: System hive<br \/>\r\n      <strong>TBWINPE_SOFTWARE<\/strong>: Software hive<br \/>\r\n      <strong>TBWINPE_DEFAULT<\/strong>: Default user hive <\/p>\r\n    <p><strong>Note:<\/strong> When BuildScript.cmd is used with TBWinPE\/RE Builder, the exported environment variables (e.g. %TBWINPE_Reg_SOFTWARE%) can be used regardless of whether or not the DISM API is used.<\/p>\r\n    <p>Example command adding an environment variable to the SYSTEM hive (DISM API not used). Command should all be on one line:<\/p>\r\n<p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>reg add  &quot;HKLM&#92;TBWINPE_SYSTEM&#92;ControlSet001&#92;Control&#92;Session  Manager&#92;Environment&quot; \/v MyEnvVar \/t REG_SZ \/d &quot;ABC&quot; \/f<\/strong><\/font><\/p>\r\n    <p>Same command as above except using the exported environment variable for the SYSTEM hive. Command should all be on one line:<\/p>\r\n    <p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>reg add  &quot;HKLM&#92;%TBWINPE_Reg_SYSTEM%&#92;ControlSet001&#92;Control&#92;Session  Manager&#92;Environment&quot; \/v MyEnvVar \/t REG_SZ \/d &quot;ABC&quot; \/f<\/strong><\/font>    <\/p>\r\n    <p>Example commands adding several custom program variables to the SOFTWARE hive. Each command should be on one line:<\/p>\r\n<p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>reg add &quot;HKLM&#92;%TBWINPE_Reg_SOFTWARE%&#92;CustomProgram&quot; \/v  Title \/t REG_SZ \/d &quot;WinPE Custom Program&quot; \/f<\/strong><\/font><\/p>\r\n    <p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>reg add &quot;HKLM&#92;%TBWINPE_Reg_SOFTWARE%&#92;CustomProgram&quot; \/v  &quot;Cache Size&quot; \/t REG_DWORD \/d 1024 \/f<\/strong><\/font><\/p>\r\n    <p><font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>reg add  &quot;HKLM&#92;%TBWINPE_Reg_SOFTWARE%&#92;CustomProgram&quot; \/v &quot;Default Path&quot; \/t  REG_SZ \/d &quot;X:&#92;Custom Files&quot; \/f<\/strong><\/font>\r\n    <\/p>\r\n    <p>While configuring and testing the build you may find it helpful to pause BuildScript after running the reg commands so you can start Registry Editor and verify the additions\/changes are being applied as desired. Remember to browse out of the mounted hives or close Registry Editor before continuing.<\/p>\r\n    <p>For details and examples on using <strong>reg<\/strong> run <font color=\"#008800\" face=\"Courier New, Courier, monospace\"><strong>reg \/?<\/strong><\/font> from a Command Prompt.<\/p>\r\n  <\/blockquote>\r\n","protected":false},"excerpt":{"rendered":"<p>This article covers several methods to add programs, scripts, and other files to the Image for Windows TBWinPE\/RE boot media using TBWinPE\/RE Builder. If you are unfamiliar with the process of creating the TBWinPE\/RE boot media, you may find it helpful to create a standard build before attempting a custom build. Tutorials for creating the [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"lsvr_kba_cat":[1796],"lsvr_kba_tag":[2121],"class_list":["post-615","lsvr_kba","type-lsvr_kba","status-publish","hentry","lsvr_kba_cat-general-information-image-for-windows","lsvr_kba_tag-image-for-windows"],"_links":{"self":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba"}],"about":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/types\/lsvr_kba"}],"author":[{"embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/comments?post=615"}],"version-history":[{"count":5,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/615\/revisions"}],"predecessor-version":[{"id":7266,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/615\/revisions\/7266"}],"wp:attachment":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/media?parent=615"}],"wp:term":[{"taxonomy":"lsvr_kba_cat","embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba_cat?post=615"},{"taxonomy":"lsvr_kba_tag","embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba_tag?post=615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}