# Run Executable Files¶

Note

AIMMS provides a good selection of functions, such as arithmetic functions, string manipulation functions, time functions, distribution functions, file functions, and more, for app developers to build prescriptive analytics applications.

However, if you already have another program for certain tasks that you don’t want to rebuild in AIMMS or if the functionality you need is not available, you can use the Execute function to call the program from AIMMS.

## Unzipping Files Using the Execute Function¶

Here’s an example. Let’s say you need a functionality to unzip files. In your case, the input files, taken from the archive directory, are currently zipped. You need to unzip them before reading. You have the application, unzip.exe, installed in the “C:Program Files” for you to use. Then you can use the following code in your AIMMS procedure to unzip the input files:

Execute("C:\\ProgramFiles\\unzip.exe", "D:\\data\\archive\\inputfile.zip");


It works as executing the command line: "C:\Program Files\upzip.exe D:\data\archive\inputfile.zip" from your AIMMS project directory. Of course, you don’t want to see a bunch of files unzipped in your project directory. You can fix that by modifying the statement. Simply add the “-d” option, provided by the unzip.exe, to redirect the extracted files to a temp folder:

Execute("C:\\ProgramFiles\\unzip.exe", "D:\\data\\archive\\inputfile01.zip -d D:\\temp\\files\\");


Instead of using double quoted strings, you can also use string parameters to generate a command line dynamically based on data in your AIMMS model. See also Execute()

MyCommandLine := FormatString("-jar RetrieveData.jar %s %s",ID, RequestDate);

where “MyCommandLine”, “ID” and “RequestData” are string parameters in AIMMS. “ID” and “RequestDate” take dynamic value at run time, and “MyCommandLine” is generated based on these values.  See also FormatString().