Reputation: 123
I have some folders and files that are installed to directory C:\
.
I want to uninstall or delete that folders and files after one year automatically.
Upvotes: 1
Views: 499
Reputation: 202474
Just schedule the uninstall to be run at the specified date.
Use schtasks.exe
tool. See also How to add a scheduled task with Inno Setup.
An simple example:
[Run]
Filename: "schtasks.exe"; \
Parameters: "/Create /RL HIGHEST /SC ONCE /SD ""{code:GetUninstallDate}"" /ST 00:00 /F /TN ""Uninstall My App"" /TR ""'{uninstallexe}' /verysilent"""; \
Flags: runhidden
[UninstallRun]
Filename: "schtasks.exe"; \
Parameters: "/Delete /F /TN ""Uninstall My App"""; \
Flags: runhidden
[Code]
function GetUninstallDate(Param: string): string;
var
Year, NextYear: string;
begin
{ schtasks needs localized date string }
Result := GetDateTimeString('ddddd', #0, #0);
{ calculate the next year }
Year := GetDateTimeString('yyyy', #0, #0);
NextYear := IntToStr(StrToInt(Year) + 1);
StringChange(Result, Year, NextYear);
end;
Upvotes: 2