Inno Setup Execute a batch file before [Files] section

前端 未结 3 694
北恋
北恋 2021-01-04 19:14

Currently my batch file is in [Run] section. I need my batch file to execute before the [Files] section. Is there a way to do this in Inno Setup? Currently the [Run] section

3条回答
  •  一个人的身影
    2021-01-04 20:05

    Continuing Deanna's great answer, code example:

    [code]
    function PrepareToInstall(var NeedsRestart: Boolean): String;
    var
       ResultCode: integer;
    begin
       Exec(ExpandConstant('{app}\serviceDeployment\unInstallService.bat'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
    end;
    

    this code always returns an empty string, which tells the setup to continue. In case you want to stop setup (in some error cases) you need to return a non empty string and it will be displayed to the user (and setup will be stopped).

    In order to return an error string add this line in PrepareToInstall's:

    Result := 'Your Error Description';
    

提交回复
热议问题