我想在[Code]
section中从[UninstallRun]
section获取参数。安装时我在调试输出中“找不到”。我在安装时没有调用CheckGetFile()
...而且在卸载时没有调用GetFilePath()
和CheckGetFile()
.WHY?
这是我的剧本
[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;
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;