我想从[Code]
部分的[UninstallRun]
部分获取参数。安装时,在调试输出 中显示“未找到”。我在安装时没有调用CheckGetFile()
,在卸载时也没有调用GetFilePath()
和CheckGetFile()
。为什么?
这是我的脚本
[Code]
Var
Check: Boolean;
function GetFilePath(Default: String): String;
begin
log('GetFilePath()');
Check := false;
Result := '';
{ do something }
if (Found) then
begin
Check := true;
Result := TargetPath;
end;
end;
function CheckGetFile: boolean;
begin
if (Check) then
begin
log('Found File');
Result := true;
end;
if (not Check) then
begin
log('not found');
Result := false;
end;
end;
[UninstallRun]
Filename: "{app}\MyApp.exe"; Parameters: "{code:GetFilePath}"; Check: CheckGetFile();
更新
[Code]
Var
TargetPath: String;
function GetFilePath(): Boolean;
begin
Result := false;
{ do something }
if (Found) then
begin
TargetPath := 'C:\Windows\xxx';
Result := true;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
ResultCode : Integer;
begin
if CurUninstallStep = usUninstall then
begin
if (GetFilePath) then
begin
Exec(ExpandConstant('{app}\MyApp.exe'), '/q /u' + TargetPath, '',
SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
end;
end;
答案 0 :(得分:2)
Check
parameter在安装时进行评估。您不能使用它来检查文件在卸载时是否存在。
为此您必须使用[Code]
:
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
ResultCode : Integer;
begin
if CurUninstallStep = usUninstall then
begin
if Check then
begin
Exec(ExpandConstant('{app}\MyApp.exe'), '', '',
SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
end;
end;