title: NSIS - Run a function after the installer released the files
body: <p>I'm using NSIS to create a simple installer, and then NsisXML plug-in by Joel to change some things in the config.xml file. </p>
  
  <p>I've created a simple function that does this:</p>
  
  <pre><code>Function ChangeConfig
  ${nsisXML-&gt;OpenXML} "$INSTDIR\configHexd.xml"
  ${nsisXML-&gt;CreateElement} "/config/config_hexd/paramlist" "param" ""
  ${nsisXML-&gt;SetElementAttr} "/config/config_hexd/paramlist/param[10]" "name" "logPath"
  ${nsisXML-&gt;SetElementAttr} "/config[0]/config_hexd/paramlist/param[10]" "value" "$INSTDIR/logs"
  ${nsisXML-&gt;CloseXML}
  FunctionEnd
  </code></pre>
  
  <p>and I'm calling it like this:</p>
  
  <pre><code>; Finish page
  !define MUI_FINISHPAGE_RUN "$INSTDIR\run.exe"
  !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\readme.txt"
  !define MUI_PAGE_CUSTOMFUNCTION_PRE ChangeConfig
  !insertmacro MUI_PAGE_FINISH
  </code></pre>
  
  <p>The script compiling goes well and I get my setup.exe. The only problem is, the setup crashes with an 'unknown runtime error' when it's copying the files. This only happens when I'm using this function, if I don't call it everything goes well. Also everything goes well if I just open and close the XML file without trying to write into it. It only crashes when I try writing into the file.</p>
  
  <p>I think that's because the installer tries writing to the file before it's done copying it over, and I'm wondering how I can prevent that. </p>
  
  <p>Thanks!</p>