Finally Sections

Top  Previous  Next

 

A Finally section is used to define commands to be run automatically even after an error is thrown elsewhere in the script. If you wish to create a Finally section it is strongly recommended that you create it after any Setup Section, Notification Section and Catch Section, and you MUST create the section before any User Sections defined in the script or an error will be thrown.

 

Command Syntax

 

If you wish to create a Finally section, you simply type the word Finally into the script surrounded by square brackets:

 

[Finally]

lamp IMPORTANT: The Finally section should follow any Setup, Notification and Catch section and appear before any other sections.

Example

 

This example uses the VarEquals condition to determine if a file has been saved, and if so attempts to delete it:

 

[Setup]

Var:FileName,"C:\MyFile.txt"

Var:FileSaved,False

 

[Finally]

If:VarEquals,FileSaved,True,DeleteFile:%%FileName%%

 

[Save]

Exec:FileSaver,%%FileName%%

Assign:FileSaved,True

 

 

This is only one way to do this. For example, instead you could could also use the FileExists condition to check whether or not the file actually exists rather than checking the FileSaved variable value.

lamp Important: If any command specified in the Finally section fails, no further commands in that section will be processed.

See Also: Setup Section Notification Section Catch Section User Sections Tasks Section Code Section