Setup programs usually store the second (larger) EXE in a DLL or in a
proprietary format compressed archive. The small setup app simply expands
the archive and runs the executable. As you can see, there are several
techniques one can use to create executable files.

One of the easiest techniques is to store all the files to be installed
inside the main setup application, as a resource and extract it if setup is
installation is to be done.

For your specific case, you can do the following, use resources:

Add the second program to the first one as a RCDATA resource.

When the first program is started, it automagically extracts the second
program to a temp file and starts it. Here's the code for the magic:


-----SECOND.RC file listing

SECONDAPPEXE  RCDATA "c:\Applications\Second\Second.EXE"

------ EOF

In a DOS Window:
C:\>BRCC32 FIRST.RC


------- In first.dpr add the following line:

{$R SECOND.RES}


------- Then, whenever you want to save Second.Exe to file, do the
following:

var
    SecRes : TResourceStream;
    pTemp : pchar;
    TempPath : string;
begin
    SecRes := TResourceStream.create(hInstance, 'SECONDAPPEXE', RT_RCDATA);
    pTemp := StrAlloc(MAX_PATH);
    GetTempPath(MAX_PATH, pTemp);
    TempPath := string(pTemp);
    StrDispose(pTemp);
    SecRes.SaveToFile(TempPath + 'Second.exe');
    SecRes.free;
    WinExec(pchar(TempPath + 'Second.exe'), SW_SHOW);
end;


----

Optionally, you can use CreateProcess instead of WinExec. You can also use
the API call GetTempFileName to make sure second.exe receives a unique
filename in the directory returned by GetTempPath.

In the code above, I am presuming that the path returned by GetTempPath ends
with a backslash ( \ ) character. You can also check for that.

    Source: geocities.com/huanlin_tsai/faq

               ( geocities.com/huanlin_tsai)