title: Create file in installation folder using WiX custom action
body: <p>I try to create a <a href="/questions/tagged/wix" class="post-tag" title="show questions tagged &#39;wix&#39;" rel="tag">wix</a> installer that has the need to create a file in the programme folder after Installation. For doing so, I have created a custom action, but I now have the following problem:</p>
  
  <p>In order to write the file, I need to know the installation directory from <code>session["INSTALLDIR"]</code>, which is only available if the action is executed <code>"immediate"</code>.</p>
  
  <p>However, if i run "immediate" after "install files", the target directory does not yet exist. If I run "deferred", it exists, but i cannot access <code>session["INSTALLDIR"]</code>.</p>
  
  <p>If I run "immediate" after "InstallFinalize", I can get the variable and the directory exists, but I am not elevated and hence not allowed to write the file.</p>
  
  <p>What is the correct combination for writing a file to the installation directory?</p>