How do you add installation related computed strings to InnoSetup scripts?
-
11-12-2019 - |
Question
Currently when I upgrade a program I backup the existing files to a folder named backup in the program directory eg .
Source: "{app}\filename.exe"; DestDir: "{app}\backup"; Flags: external skipifsourcedoesntexist uninsneveruninstall
Is there a way to specify or compute a strings so the code is something like
Source: "{app}\filename.exe"; DestDir: "{app}\backup{date}"; Flags: external skipifsourcedoesntexist uninsneveruninstall
or combine a date with info on the previous version
Source: "{app}\filename.exe"; DestDir: "{app}\backup{previous version}{date}"; Flags: external skipifsourcedoesntexist uninsneveruninstall
Solution
Please read Pascal Scripting: Scripted Constants and Pascal Scripting: Support Functions Reference. Also read this and this. Anyway, this is how I did it:
[Dirs]
; create an empty folder...
Name: "{app}\{code:MyDateTimeString}"
[Code]
function MyDateTimeString(Param: String): String;
begin
Result := GetDateTimeString('yyyy.mm.dd_hh.nn.ss', #0, #0);
end;
OTHER TIPS
You can add runtime dynamic values using {code:...}
constants.
An example of getting the current date and making a backup of the installation folder can be seen on the ISXKB wiki
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow