I don't know why you created a topic in the Scripts forum for your task because a script is definitely not needed for this task.
If you are using UEStudio with a compiler configuration and press the build or rebuild button, then it would be best to adapt the configuration file to your needs. The configuration file contains the rules for UEStudio, how to create in first step of a build/rebuild process the makefile executed by UEStudio on next step.
Click in UEStudio on Project - Select Compiler, then click on button Edit Configuration. The dialog changes because a second pane opens on right side of the dialog showing content of the configuration file. Scroll down to red highlighted [Build] section. You will see there some lines. Usually the last one starts with Cmd0= which is the command to build the project. You have to change the number to get Cmd1 and insert a line starting with Cmd0= and the program you want to run first before building the project.
Alternatively if you want the program executed first on every *.c file (for a C project) compiled during a build process, you have to modify the command list of section [.C]. C++ projects have often also just a [.C] section because in section General there is the line .CPP = .C.
After the modification of the configuration file you can save the modified configuration using button Save Configuration. Usually I suggest to first press button Make Configuration Locale to save the configuration in the project directory before modifying and not modifying the standard configuration as installed with UEStudio into subdirectory configs in the program files directory of UEStudio. But you want to use the modified configuration for several projects and therefore you probably don't want the configuration file stored in the project directory of the active project.
Hint: It might be a good idea to open the configuration file as displayed in Select Compiler dialog directly in UEStudio from the appropriate "UEStudio Program Files Directory\configs\Selected Compiler" directory, save it with a new name like MyApplicationConfig using Save As command into the directory, close the file, open now Select Compiler dialog, select MyApplicationConfig for this project (and later also for the others) and edit this configuration. This prevents replacing your modified configuration in the standard compiler configs directory on upgrade of UEStudio by the installer.
If the configuration file you use contains a [Show Makefile] section you can use the command Build - Run Commands - Show makefile to display the makefile in a new instance of UEStudio. You might need to run first Build - Regenerate Makefile after making the changes on the configuration file before viewing the makefile.
If you are not using UEStudio, but use UltraEdit, you run the compiler probably via a user or project tool. In this case modify the configuration of this tool by calling a batch file instead of the compiler, put into the batch file the compiler command with appropriate parameters and insert above the command to call your program which should be executed before compilation.