# Inno Setup (How to get dynamically path to file)

dynamically-generatedinno-setupinstallationpath

I'm making a setup script in Inno and I was wondering, how can I get non "hardcoded" path. Here is example:

SOLUTION:

You can get .iss folder by using predefined variable

SourcePath

Usage would be like: {#SourcePath}\???\bin\x86\Release\???.exe

Thanks all who contributed!

#### Best Solution

The reference about the `source directory` says (emphasized by me):

By default, the Setup Compiler expects to find files referenced in the script's [Files] section Source parameters, and files referenced in the [Setup] section, under the same directory the script file is located if they do not contain fully qualified pathnames. To specify a different source directory, create a SourceDir directive in the script's [Setup] section.

This includes also option to specify relative path to the files. So let's assume that you have the following file structure and you didn't specify a different path in the `SourceDir` directive:

``````C:\Deploy\Script.iss
C:\Deploy\MyProg.exe
C:\Deploy\SubFolder\MyOtherProg.exe
C:\Folder\SomeFile.txt
``````

Now if you'd like to include the `MyProg.exe` into the setup compiled from the `Script.iss` script, you could specify just the file name without the path, since the `MyProg.exe` file is stored in the same folder as the script, so you could write just:

``````[Files]
Source: "MyProg.exe"; DestDir: "{app}"
``````

And you can use a relative path to the `MyOtherProg.exe` which is stored in the subfolder of the folder where the `Script.iss` script is stored this way:

``````[Files]
Source: "SubFolder\MyOtherProg.exe"; DestDir: "{app}"
``````

As well as you can use a relative path to include the `SomeFile.txt` stored in a subfolder of the parent folder where the script is stored:

``````[Files]
Source: "..\Folder\SomeFile.txt"; DestDir: "{app}"
``````

More about relative path conventions you can read in `this chapter`.