2

I am trying to write a Inno Setup script to install files from a CD drive to a predefined system C drive folder. Naturally, the CD/DVD ROM may have a different path ID on different systems. How do I code this variable path for the Source Files?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

3

Assuming your installer is located along with the files you are going to install, you can use the {src} constant to refer to installer's folder along with the external flag:

[Files]
Source: "{src}\file.dat"; DestDir: "..."; Flags: external

If your installer is located elsewhere, there's no generic solution. Note that there may be even more CD/DVD drives on the computer.

You would have to programmatically enumerate all drives, testing for their type (CD/DVD) and presence of certain files for example.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1
    You can at least [`narrow the drive`](http://stackoverflow.com/a/12379740/960757) in which a file unique to the setup package is. – TLama Feb 11 '15 at 08:28
  • I tried that but the compiler gives me an error: No files found matching "C:\Users\Harry\Desktop\{src}file.dat" I am running the compiler from my desktop, and the source files are on a different drive (F Drive). – Harry Unruh Feb 12 '15 at 17:03
  • OK, You have to add `Flags: external` so that the compiler does not try to locate files on compile-time (when constant resolution does not work in `Source` attribute). See my updated answer. – Martin Prikryl Feb 12 '15 at 17:46