Using H7PluginBuilderFor this example we'll do something simple, (I won't test if it works in a PE afterwards because it'll need some tweaks), by creating a plugin of MyDefrag, you'll still get the general idea.
Once around the block first, (see first pic):
A - Resets the interface back to default ready for plugin creation.
B - Import a PEBuilder plugin or monitor installs from FileMon, InstallRite or InstallWatch which can then be saved as WinBuilder plugins.
C - Batch conversion of PEBuilder plugins.
D - Import a .reg file and save as a PEBuilder/WinBuilder plugin.
E - Monitor the installation of a program and capture its registry entries and files to be saved as a plugin.
F - Allows you to select an .ocx or .dll and then capture the registry change when it's registered.
G - PEBuilder specific settings.
H - WinBuilder specific settings.
J - H7PluginBuilder specific settings.
K - Whether or not the generated plugin will be enabled in PEBuilder/WinBuilder by default.
1 - Enable if you want to be able to choose an output folder at 2.
I don't know if D, E & F work - I've never used them. I do know it will convert PEBuilder plugins but WinBuilder can do that also.
Set up H7PluginBuilder, (H7PB), as follows, (choose your own Target dir of course):

Set the WinBuilder options as follows, (click button
H in first pic):

Click the Explorer tab at the bottom of the left panel and then right-click the Programs folder and select Grab Folder:

Select the MyDefrag folder in C:\Program Files

All the files will now show up in the explorer panel, untick the ones not required:

Click on the Registry tab at the top of the panel, right-click HKEY_CURRENT_USER and select Import:

The .reg file being imported is the registry entries MyDefrag creates in HKCU/Software/MyDefrag, (go into regedit and just export them):

The entries will be imported and you'll have the following:

By clicking the Blue line under the panel you can edit/add various entries:

Right-click on the last entry and select Remove:

Go back to the Main tab, right-click on the MyDefrag.exe file, select Properties and set as below, change Shortcut->QuickLaunch->Create to
True and edit WinBuilder->Section to say
Files. After that click the Explorer tab at the bottom and for the rest of the files being added also change WinBuilder->Section to
Files:


These shows what files we are keeping from all the added ones, click the Build button. If the Target file already exists then you will get a warning exclamation mark up the top right:

The result panel will show the basic script
without the encoded files. The actual MyDefrag.script in the output directory will contain the files encoded within it, (that's why it's 996KB):

The resulting script is attached as is some working plugins I made for WinBuilder VistaPE011.