0
votes

I can achieve my objective on MacOSX using applescript which installs a text-like file and then inserts a few lines of text into the program's settings file in the same folder. Final window has a launch option for the main program. For Windows, Inno Setup installs the file and then installs a second file which 'replaces' the settings file in the user's program appdata settings folder (as recommended by the program developer.) This is fine for new users but experienced users will not want their main settings file replaced.

My objective is to replicate the Mac process. Only way I know is to use a batch file (works on Win XP and 8) to insert the text into the settings file already on disk. AFAIK the batch file needs to be in same folder. Thus, the installer installs the initial file, then the batch file. This batch exe file needs to be 'run' and I want to find a method of deleting the batch file immediately after. Then the process is finished and proceed to final Inno Setup window. Is this possible and if so, how? Some sample code would be ideal if possible.

If there is a better approach than using a batch file, then that might be a better solution so there's no need to delete any files.

I've learnt a lot about using Inno Setup via StackOverflow over the past year but cannot find a solution to the above. This is a community project.

1

1 Answers

1
votes

You can use the Inno Setup Pascal Scripting support and it's support classes and functions. Something like this should work:

procedure CurStepChanged(CurStep: TSetupStep);
var
  Lines: TStringList;
  FileName: string;
begin
  if CurStep = ssPostInstall then
  begin
    FileName := ExpandConstant('{app}');
    FileName := AddBackslash(FileName) + 'YourFile.txt';
    Lines := TStringList.Create;

    // Load existing lines from file
    Lines.LoadFromFile(FileName);
    // Add your information to the end of the file
    Lines.Append('Your changed information'); // Repeat as needed
    Lines.SaveToFile(FileName);
    Lines.Free;
  end;
end;

You can find an example of calling the function above from the CodeExample1.iss file located in the Inno Setup Examples folder.