title: Downloading and copying file using the WIX toolset
body: <p>I'm working on adding a feature to our WIX-based installer. It's my first time working with WIX so it's all quite new to me.</p>
  
  <p>What I'm trying to do is allow users to pass an auth token command line argument when using <code>msiexec</code>.</p>
  
  <p>The installer will then make an API call with the auth token. If the auth fails, the installer will terminate. Otherwise, the installer will download a file using the API and copy it over to the install directory (most likely under <code>Program Files</code>).</p>
  
  <p>I've managed to read in the command line arguments as properties in WIX and have created a CustomAction in C# to handle the authentication / downloading the file.</p>
  
  <p>The part I'm struggling with is getting the CustomAction to copy the file into the install location, as it doesn't have privileges to write to the location.</p>
  
  <p>I can have it run with elevated privileges by setting <code>execute="deffered"</code> and <code>"impersonate=no</code> however that prevents me from reading in properties from the <code>session</code> object.</p>
  
  <p>Another possible option is to save the file to a temp location in the CustomAction (which works without elevated privileges) and set a new property. Then I can use the <code>CopyFile</code> component with <code>SourceProperty</code> to copy that file to the target location.</p>
  
  <p>I'm unable to figure out, however, how to get the CustomAction to run before the <code>CopyFile</code> component, as the property wouldn't be set until after the CustomAction has been run. Is it as simple as simply running running the CustomAction <code>before</code> a specific part of the install, or is there more to it?</p>