Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get path to the current InnoSetup script file?

Tags:

inno-setup

How to get path, where the InnoSetup script file you are currently compiling is located ?

like image 657
myWallJSON Avatar asked Sep 25 '12 14:09

myWallJSON


People also ask

What is Inno Setup file?

Inno Setup is a free software script-driven installation system created in Delphi by Jordan Russell. The first version was released in 1997.

How do I Setup Inno Setup?

Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.

What is Inno Script Studio?

Inno Script Studio is a new intuitive graphical interface for generating and compiling scripts for the award winning Inno Setup compiler from Jordan Russell.

What language does Inno Setup use?

Inno Setup's [Code] section uses Pascal (or Pascal Script to be more exact, thanks to TLama), likely because Inno Setup itself is written in Pascal Delphi.


1 Answers

To get script source path, use the preprocessor's predefined variable SourcePath. That variable you can expand in your script as an ordinary define. In case, the script was not yet been saved, it returns path to My Documents directory. Here's just a useless example to test:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Code]
procedure InitializeWizard;
begin
  MsgBox(ExpandConstant('{#SourcePath}'), mbInformation, MB_OK);  
end;

Don't forget that you have to compile the script (CTRL + F9) not only run (F9) to invoke preprocessor to rebuild the script.

like image 129
TLama Avatar answered Sep 19 '22 11:09

TLama