Search code examples
batch-fileexeiexpress

.exe file execution from within


If I make a file foo.exe, and it contains the files bar.bat, baz.bat, and qux.bat, can I call baz.bat from within bar.bat? I mean, if bar.bat is the file that is executed upon execution of foo.exe?


Solution

  • I had done something similar using winrar (instead of iexpress) self extracting archive.

    The mechanism is like below:

    1. First it will extract everything to specified folder (or in temporary folder %TEMP%/random_name)
    2. Then it will call initial executable/script or "script to run after extraction". In your case, it's bar.bat.
    3. That executable script can in turn call any other script/executable. (baz.bat in your example)

    To be sure, change the file bar.bat to contain below script:

    @echo off
    cd
    explorer .
    pause
    

    This will print the directory name, where it has extracted & open the directory with explorer.exe. Then you can verify that your baz.bat is in same directory. Give relative path, if required.