13

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

4
  • Just to clarify, are you after the 1) location the .iss file at compile time, 2) the location of the final output setup.exe at compile time, or 3) the location of the setup.exe while installing? Commented Sep 25, 2012 at 15:05
  • I am after location the .iss file at compile time. Commented Sep 25, 2012 at 15:08
  • 1
    Get script source path is as easy as ExpandConstant('{#SourcePath}'), but script file name... What you gonna do with that information, anyway ? Commented Sep 25, 2012 at 15:27
  • 1
    @TLama - The question asks the path only. That should answer the question. Commented Sep 25, 2012 at 15:35

1 Answer 1

16

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.

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

2 Comments

You don't have a "CTRL+F9" key ? Strange :-)
you are so right and I thank you for your service to our community. {#SourcePath}\ just worked. I love it when things just work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.