title: AWS EC2 Windows UserData script not running
body: <p>I have a windows batch script that runs locally and also runs on the EC2 when I run it manually. However, when I try to launch an ec2 via the CLI and I feed in the script in the user-data parameter it does not run.</p>
  
  <p>This is the script:</p>
  
  <pre><code>for /l %%x in (20171101,1,20171102) do (
  start "S3Copy" C:\Progra~1\Amazon\AWSCLI\aws s3 cp 
  s3://bucket1/%%x s3://bucket2/%%x --recursive
  )
  
  echo waiting
  :loop
  timeout 1 &gt;nul
  tasklist /v |find "S3Copy" &gt;nul &amp;&amp; goto :loop
  echo all of them are finished
  
  shutdown.exe /s /t 00
  </code></pre>
  
  <p>When I pass it into UserData I surround it with:</p>
  
  <blockquote>
    <p>[script] [/script] (angle brackets)</p>
  </blockquote>
  
  <p>Yet it does not run like this.</p>
  
  <p>As I have stated, I can log into the same Ec2 that was launched and I can run the script manually and works as expected.</p>
  
  <p>I will say, when I log in manually I use a specific user, when I launch from cli, it uses a specific Key file, which could use a different user, but the .aws config is set up for all users on that AMI.</p>
  
  <p>What might be missing here?</p>