title: How to start a program on instance start on AWS EC2
body: <p>I have a AWS EC2 Windows (2008 R2 instance) which I want to start-stop using command/script from my local machine and schedule as per my usage.
  I also want couple of my programs running on the EC2 instance to get start when instance starts. These programs currently are started using a bat file present in the instance. </p>
  
  <p>I did following till now for the same:</p>
  
  <p>1- I have an AWS user created in AWS IAM and using auth_id and key for that user for using EC2 apis and command line utilities.</p>
  
  <p>2- To start and stop instance I'm using command line utilities from EC2 Util.</p>
  
  <pre><code>start -&gt;ec2-start-instances i-instanceID
  
  stop  -&gt;ec2-stop-instances i-instanceID
  </code></pre>
  
  <p>3- To schedule it I've added this to my windows scheduler.</p>
  
  <p>4- Added user data for the instance in the AWS management console. My user data looks like this:</p>
  
  <pre><code>&lt;script&gt;
  C:\Services\my_application.lnk
  &lt;/script&gt;
  </code></pre>
  
  <p>5- I can see the user data is present in my EC2 instance at C:\ProgramFiles\Amazon\Ec2ConfigServer\Scripts\UserScript</p>
  
  <p>6- In C:\Program Files\Amazon\Ec2ConfigService\Settings\confi.xml the values of Ec2SetPassword and Ec2HandleUserData were changed to enabled and added true was added as well.</p>
  
  <p>I'm facing following issues:</p>
  
  <p>1- The user data scripts does not execute every time the instance is started. I'm not able to figure out why.
  2- The changes made in Ec2ConfigService\Settings\confi.xml are getting reverted to the default values when the instance is restarted.</p>
  
  <p>I feel this is common use case, and would like to know the best practices and approach taken for automating EC2 operations. 
  I also need help in starting programs on my instance- where am I going wrong or missing, what else needs to be done etc?</p>