3

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
vfclists
  • 19,193
  • 21
  • 73
  • 92
  • 2
    See [this article](http://www.vincenzo.net/isxkb/index.php?title=Backup_of_application_directory) for an example. – Deanna Mar 12 '12 at 11:51
  • 1
    @Deanna, +1. very nice example. maybe you should post that code as an answer (not sure). a side comment, I think that a backup to "{app}" directory is a very bad idea (specially if it's in the Program Files). "Common App Data" or even the "Temp" folder is a better idea. – kobik Mar 13 '12 at 12:05
  • @kobik: Posted. I don't use or condone it, but some people want and think they require it :) – Deanna Mar 13 '12 at 12:41
  • 2
    I have realized that saving information to Program Files is a bad idea after Vista and Windows 7. I get away with it on Windows XP but that is going to change. – vfclists Mar 14 '12 at 11:49

2 Answers2

4

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

Deanna
  • 23,876
  • 7
  • 71
  • 156
  • I had to award @Gregory because he responded first. Only 35 points, really an SO newbie!! – vfclists Mar 14 '12 at 11:51
  • 1
    Check your times :) But yes, I tend to vote up the more fuller answers and newer users too. – Deanna Mar 14 '12 at 11:55
  • 1
    I am into inno-setup most of my time these days, since I am moving away from NSIS and going towards INNO fast! Thus, I was able to help with this one and also help myself, that was trying something similar. I guess this is why StackOverflow is so great; in concept and implementation! Greets to all (and try to chill out with that voting thing! LOL) –  Mar 14 '12 at 13:03
4

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;
Community
  • 1
  • 1