12

I'd like to call a batch file at the start of an Inno Setup compile process. i.e. before it starts compiling, perform an external operation. Is this possible or should my external activity be wrapping the Inno Setup compile process?

0

3 Answers 3

20

If you have ISPP installed with Inno (It's built in now) then you can use the Exec() preprocessor function to run your batch file. The compile will be paused until it returns (place it at the beginning of your file).

#expr Exec("c:\file.bat")

If your command takes arguments, you have to write it as:

#expr Exec('c:\my_cmd.exe','some_argument') 

You can also run it from a batch file that then calls the setup compiler.

Sign up to request clarification or add additional context in comments.

Comments

2

As an addendum to the accepted answer, here is the documentation for Exec() in case the help pages ever go down.

Inno Setup Preprocessor: Exec

Prototype
int Exec(str 1, str? 2, str? 3, int? 4, int? 5)

Description
Executes specified executable file.

First argument specifies the filename of the module to execute.

Second argument may be used to specify command line to execute.

Third argument may be used to specify the working directory of the process.

Fourth argument should be set to zero, if you don't wish to wait for the process to finish, and non-zero otherwise. By default, non-zero value is assumed.

Fifth argument can be any of the SW_* constants defined in ISPPBuiltins.iss file. For GUI processes, it specifies the default value the first time ShowWindow is called. By default, SW_SHOWNORMAL (i. e. 1) is assumed.

If fourth argument is omitted or is non-zero, the function returns the exit code of the process. Otherwise, the function result indicates whether the process has been successfully launched (non-zero for success).

Comments

0

As I needed the answer to this question, I thought I would expand on it a bit more.

If you want to run a batch file on compile, the answer above is perfect.

I did this to run a batch file that auto committed the project folder to SVN. Works for all the software department as I created this inno as a template for all releases.

To expand on the answer above:

Batchfiles may take more than one argument,

#expr Exec() only has the second argument for your string of command line arguments.

Therefore, if you need to pass the batch file more than one argument, concatenate the arguments as such:

#expr Exec(BatchFilePath, MyOutputDir + " " + MyAppName + " " + MyAppVersion)

so it is still Exec([targetfile],[stringofarguments])

Hope this helps

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.