【发布时间】:2014-09-09 18:48:17
【问题描述】:
我需要我的卸载来运行命令在它删除了它已安装的文件。 [UninstallRun] 没有用,因为我知道它在文件被删除之前运行。 我有点需要一个“postuninstall”标志。
关于如何完成上述任务有什么建议吗?
【问题讨论】:
标签: inno-setup
我需要我的卸载来运行命令在它删除了它已安装的文件。 [UninstallRun] 没有用,因为我知道它在文件被删除之前运行。 我有点需要一个“postuninstall”标志。
关于如何完成上述任务有什么建议吗?
【问题讨论】:
标签: inno-setup
请参阅文档中的“Uninstall Event Functions”。例如,当 'CurUninstallStep' 为 'usPostUninstall' 时,您可以使用 CurUninstallStepChanged。
【讨论】:
同样有一个 [Run] 部分,Inno 允许您定义一个 [UninstallRun] 部分来指定应在 unistall 上执行安装程序包的哪些文件。
例如:
[UninstallRun]
Filename: {app}\Scripts\DeleteWindowsService.bat; Flags: runhidden;
另外,@Sertac Akyuz 提出的利用事件函数的解决方案可用于调整更多的 unistalling 动作。下面是 CurUninstallStepChanged 函数在其他相关函数中的使用示例。
https://github.com/HeliumProject/InnoSetup/blob/master/Examples/UninstallCodeExample1.iss
; -- UninstallCodeExample1.iss --
;
; This script shows various things you can achieve using a [Code] section for Uninstall
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
[Code]
function InitializeUninstall(): Boolean;
begin
Result := MsgBox('InitializeUninstall:' #13#13 'Uninstall is initializing. Do you really want to start Uninstall?', mbConfirmation, MB_YESNO) = idYes;
if Result = False then
MsgBox('InitializeUninstall:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
end;
procedure DeinitializeUninstall();
begin
MsgBox('DeinitializeUninstall:' #13#13 'Bye bye!', mbInformation, MB_OK);
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
case CurUninstallStep of
usUninstall:
begin
MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall is about to start.', mbInformation, MB_OK)
// ...insert code to perform pre-uninstall tasks here...
end;
usPostUninstall:
begin
MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall just finished.', mbInformation, MB_OK);
// ...insert code to perform post-uninstall tasks here...
end;
end;
end;
【讨论】:
[UninstallRun] 由于安装顺序不合适。