0 votes
1 view
in AWS by (19.2k points)

I'd like to launch an EC2 Windows instance, upload an EXEcutable & execute it (all in an automated fashion, this is important)

So far I was able to programmatically launch EC2 Windows instance & get its parameters (password / IP), now I'd like to find a way to upload this Executable (from my Windows machine or from my other EC2 Linux instance) & run it.

I thought about launching an RDP connection & using a macro software to upload & execute the file, but based on previous experiences this is a poor/fragile approach, to say the least.

I also thought about uploading this EXE to a server, then do something like this on Windows:

wget http://www.domain.com/my-file.exe

Except that Windows doesn't have wget!

So my question is: is there a way to programmatically upload & execute an EXEcutable in EC2 Windows instance?

1 Answer

0 votes
by (44.6k points)

In Windows, there is no default service like wget to execute the user-data-file when the instance gets booted. But, you can use this open source project CloudInit.NET project. But you will require .NET 4.8 (latest version) and CloudInit.NET installed in Windows instance. Then you can use this below command’s to execute the user-date-file:

!# /powershell/

$wc = New-Object System.Net.WebClient

$wc.DownloadFile("http://www.yourdomain.com/your-file.exe", "C:\your-file.exe");

& 'C:\your-file.exe'

Also, if you want this to be available whenever you need, then create an AMI of this instance and use it to launch your instance so that all of this will be installed already.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !