I am creating an installer in order to update a service. My idea is:
- Stop Service
- Backup all files and folders in a folder named
backup
. - Remove all files and folders
- Copy (install) new files and folders
- Copy some files (configuration files) from
backup
overwriting new files created.
This is my code actually:
[Run]
;1. Stop service
Filename: "{sys}\sc.exe"; Parameters: "stop ""myService"
[Files]
;2. Create temporally backup
Source: {app}\*; Excludes: "backup"; DestDir: {app}\backup\backup{code:GetTodaysName}; \
Flags: external skipifsourcedoesntexist recursesubdirs createallsubdirs
;Install new version.
Source: "{#MyInstalerPath}\bin\*"; DestDir: "{app}"; \
Flags: ignoreversion recursesubdirs createallsubdirs
;Restore config files.
Source: "{app}\backup\backup{code:GetTodaysName}\myService.Configuration.xml"; \
DestDir: "{app}"; Flags: external
[Code]
var
TodaysName : String;
function GetToday : String;
begin
Result := GetDateTimeString ('yyyymmddhhnnss', '-', #0);
end;
function GetTodaysName (Param: String): String;
begin
if ('' = TodaysName) then
begin
TodaysName := GetToday ();
end;
Result := TodaysName;
end;
I have problems in parts 2 and 3. I should avoid backup folder in backup
process, but I can't use both Excludes
and external
.
Anyone can help with this issues? Thanks