title: Inno Setup: How to run a code procedure in Run section or before Run section?
body: <p>I want to remove the old database before installing the new one, to update it for the user.</p>
  
  <p>I have the following scenario:</p>
  
  <p>In my <code>Components</code> section I have an option for the user:</p>
  
  <pre><code>[Components]
  Name: "updateDatabase";  Description: "Update Database";  Types: custom; \
      Flags: checkablealone disablenouninstallwarning
  </code></pre>
  
  <p>And I have in <code>Code</code> section, a procedure to execute, if the user selects this option, in the run section, before installing the new one.</p>
  
  <pre class="lang-pascal prettyprint-override"><code>[Code]
  procedure RemoveOldDatabase();
  begin
  ...
  end;
  
  [Run]
  **--&gt; Here I want to call RemoveOldDatabase if Components: updateDatabase is checked**
  Filename: "database.exe"; StatusMsg: "Installing new database..."; Components: updateDatabase
  </code></pre>
  
  <p>The installation of the new database works fine. The problem is I want to remove the old one before installing the new one, calling the procedure <code>RemoveOldDatabase</code>.</p>
  
  <p>Is it possible by only using Inno Setup?</p>
  
  <p>Thanks.</p>