Inno Setup:如果程序文件夹中存在文件,则关闭安装程序向导 [英] Inno Setup: Close installer wizard if file exists in the program's folder

查看:393
本文介绍了Inno Setup:如果程序文件夹中存在文件,则关闭安装程序向导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个演示版安装程序,如果该安装程序在程序文件夹中检测到文件close.txt,则它将关闭向导或中止安装.

I am trying to create an installer that is a Demo installer that if it detects the file close.txt in the programs folder then it closes the wizard or aborts install.

我正在运行一个计划任务,该任务将在两天后自动卸载该应用程序.初次安装时,close.txt文件将安装在programs文件夹中,然后在自动卸载后,close.txt文件将保留在programs文件夹中.我希望当您重新运行安装程序时,它会检查该文件,以及是否发现该文件会关闭向导或中止安装.我是新手,我认为可以在代码部分中完成此操作,但我不确定.

I am running a scheduled task that automatically uninstalls the app after two days. On initial install the close.txt file gets installed in the programs folder then after auto uninstall the close.txt file is left in the programs folder. I would like for when you re run the installer it checks for this file and if it is found to close the wizard or abort install. I am a newbie at this I think it can be accomplished in the code section but I am not sure.

任何帮助或代码片段都将不胜感激!

Any help or code snippets would be appreciated thank you!

推荐答案

测试文件是否存在于 InitializeSetup事件函数,并返回False(如果存在).

Test for the file existence in InitializeSetup event function and return False, if it exists.

[Setup]
DefaultDirName={autopf}\My Program

[Code]
function WasMyProgramEverInstalled: Boolean;
begin
  Result := FileExists('{#SetupSetting("DefaultDirName")}\close.txt');
end;

function InitializeSetup: Boolean;
begin
  Result := True;
  if WasMyProgramEverInstalled then
  begin
    MsgBox('Some message', mbError, MB_OK); { Optionally }
    Result := False;
  end;
end;

请注意,如果安装程序允许自定义安装路径,则在卸载后重新运行安装时,您将不知道该路径.所以这行不通.

这篇关于Inno Setup:如果程序文件夹中存在文件,则关闭安装程序向导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆