I want to start a batch file from [Files]
section.
It works with absolute path like
[Files]
#expr Exec("C:\batch.bat");
but how can I start it with relative path? My batch file is located in the same directory as the .iss file.
I have tried it with
#expr Exec("\Batch.bat");
or something like
#expr Exec("{#SourceDataPath}\Batch.bat");
and with
#expr Exec(ExpandConstant("{#SourceDataPath}\Batch.bat"));
but it just says "Undeclared identifier: ExpandConstant."
But everything I have tried did not work.
Use SourcePath
preprocessor predefined variable:
#expr Exec(SourcePath + "\Batch.bat");
Note that it's not really correct to say that you execute the batch file from the [Files]
section. It might confuse you to think of it this way. You are executing the batch file in a preprocessing phase. Unless you use results of the batch file in further preprocessor directives (what I believe you do not), you can actually place the Exec
call anywhere in the script file. As I believe your batch file only produces files, which are used in the compiling phase that happens only after the complete script is preprocessed. Though it's perfectly fine to place the call where you put it. It's just so that you understand what going's on under the hood.