Search code examples
inno-setuppascalscript

Write Inno Setup environmental variable (srcexe) to a file


I would like to write the srcexe (Should return c:\setup.exe) to a file in my application folder.

Here is what I have tried. However the file gets created but it is empty.

Maybe im running in the wrong procedure or I'm calling incorrectly.

[Code]
procedure DeinitializeSetup();
var Path : string;
begin
  Path := GetEnv('srcexe');
  SaveStringToFile('C:\appname\filename.txt',Path, False);
end; 

Solution

  • The srcexe is not an "environmental variable", it's an Inno Setup constant.

    To expand the constant, use the ExpandConstant function with a proper constant syntax (curly brackets).

    Path := ExpandConstant('{srcexe}');