EC2WinInit Tool and Utilities

I use windows instances on Amazon EC2 frequently for different tasks, and I wanted a quick and easy way to be able fire up one or more instances to execute a specific program. One caveat is that Amazon has a service that configures aspects of the instance after sysprep and after it starts up for the first time. This configuration needs at least 1 reboot. The indicator for when you can actually proceed with what you need to do is that "Windows is ready to use" will be output to the Ec2ConfigLog and to the console. So I created a service, which I call EC2WinInit, that will wait for the "Windows is ready to use" message and then will kick off any arbitrary executable you want. In addition, I created several other utilites to use in conjunction with this service that can run a program in an interactive session or download and execute arbitrary packages that you create from either HTTP or S3. This gives a lot of flexibility for automating Windows EC2 instances.

NOTE: I know that amazon has added the ability to add a <script> or <powershell> command to user data when launching an instance. I wanted something a bit more flexible that had the option of baking-in configuration scripts/packages.

Here are the utilities that I created:

Installing the Service and Basic Usage

  1. Download the utilities here:
  2. Launch a windows instance and configure it as desired
  3. Create a folder on the machine for the EC2WinInit service such as
    C:\Program Files\EC2WinInit
  4. Extract the zip file downloaded in step 1 into the folder
  5. Open an administrator command prompt run the following command (This will install the service):
    sc create EC2WinInitService binPath= "C:\Program Files\EC2WinInit\EC2WinInitService.exe" start= auto
  6. Also from the command prompt, run the following command
    "C:\Program Files\EC2WinInit\EC2WinInitPrep.exe"
  7. Open the c:\Program Files\EC2WinInit\EC2WinInitService.exe.config file
    Here you can customize the program that will be run when "Windows is ready to use". This program will be executed by the service in non-interactive mode. If you need to run something in an interactive session, leave the command to be "DAR\ConfigInteractive.exe". If you want to download a DAR package specified in the metadata, change the command to be "DAR\ DARFromMetadata.exe". Or specify you own command and command arguments.
  8. If you specified "DAR\ConfigInteractive.exe" in the step above, edit the ConfigInteractive.exe.config file location in the directory. Customize the RunCommand and/or RunOnceCommand and the respective arguments to your liking. If you want to download a DAR package specified in the metadata, leave the RunOnceCommand to be "DAR\DARFromMetadata.exe".
  9. Run "ec2configservice settings" from the start menu
  10. The following are recommended settings for the ec2config service:
    • Check off "set the computer name of the instance to ip-<hex Internal IP> name."
    • Check off "set a random password on next boot"
    • Check off "enable SetPassword feature"

  11. Click the Bundle tab and "Run sysprep and Shutdown Now"
  12. After the machine shuts down, create an AMI image

Creating a dar package

NOTE: you do not need to use the DAR program to use the EC2WinInit service. This just provides extra functionality if you want it.

To create a dar package, simply create a run.cmd file or a dar.xml file (see below) and zip it up along with any other files you will need for your script/program to run. Place this file on a web server or s3 bucket, and when you run DAR.exe with the url as a paramter, the zip file will be downloaded, extracted and executed.

Example dar.xml file

<?xml version="1.0" encoding="utf-8"?>
<DarManifest xmlns:xsi="" xmlns:xsd="">
  <Arguments />

Example DAR package

Click here to download an example dar package

Specifying a dar package in user data

The DARFromMetadata.exe will look for specific tags specified in user data of the instance and launch DAR.exe with the url specified in the user data. To use this, simply include the following string in your instance user data:



comments powered by Disqus