如何将安装相关的计算机字符串添加到InnOSetup脚本?
-
11-12-2019 - |
题
当前当我升级程序时,我将现有文件备份到程序目录中名为备份的文件夹,例如。
Source: "{app}\filename.exe"; DestDir: "{app}\backup"; Flags: external skipifsourcedoesntexist uninsneveruninstall
.
有没有办法指定或计算字符串,以便代码是的东西
Source: "{app}\filename.exe"; DestDir: "{app}\backup{date}"; Flags: external skipifsourcedoesntexist uninsneveruninstall
.
或将日期与上一个版本的信息合并为
Source: "{app}\filename.exe"; DestDir: "{app}\backup{previous version}{date}"; Flags: external skipifsourcedoesntexist uninsneveruninstall
. 解决方案
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;
其他提示
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
不隶属于 StackOverflow