2

I am quite new to AWS but I think I understood how to deploy an EC2 instance, what I am trying to do is install apache tomcat and all that is needed for this on a windows server 2016 using the user data field in the instance creation. My problem comes, I think, from the fact that i need to declare new pathes for jre, jdk and awscli. Is there a way to do it ?

Here is my scrypt:

<script>
powershell "& {$url='https://s3.amazonaws.com/aws-cli/AWSCLI64.msi';$clnt=new-object System.Net.WebClient;$clnt.DownloadFile($url,'C:\Users\Administrator\Downloads\installer.msi')}"
C:\Users\Administrator\Downloads\installer.msi /qn
setx PATH "%PATH%;C:\Program Files\Amazon\AWSCLI"
setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0_181"
setx JRE_HOME "C:\Program Files\Java\jre1.8.0_181"
echo aws s3 cp s3://andrea-s-buckets999/followingScript2.bat C:\Users\Administrator\Downloads > C:\Users\Administrator\Downloads\followingScript.bat
echo aws s3 cp s3://andrea-s-buckets999/apache-tomcat-8.0.53.exe C:\Users\Administrator\Downloads >> C:\Users\Administrator\Downloads\followingScript.bat
echo aws s3 cp s3://andrea-s-buckets999/jdk-8u181-windows-x64.exe C:\Users\Administrator\Downloads >> C:\Users\Administrator\Downloads\followingScript.bat
echo aws s3 cp s3://andrea-s-buckets999/jre-8u181-windows-x64.exe C:\Users\Administrator\Downloads >> C:\Users\Administrator\Downloads\followingScript.bat
echo C:\Users\Administrator\Downloads\jdk-8u181-windows-x64.exe /s >> C:\Users\Administrator\Downloads\followingScript.bat
echo C:\Users\Administrator\Downloads\jre-8u181-windows-x64.exe /s >> C:\Users\Administrator\Downloads\followingScript.bat
echo C:\Users\AdministratorDownloads\followingScript2.bat >> C:\Users\Administrator\Downloads\followingScript.bat
C:\Users\Administrator\Downloads\followingScript.bat
</script>
1

You need to read the path and append the new path and overwrite it

in PowerShell code

$OldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path

$NewPath=$OldPath+’;C:\Something\...\....\bin’

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.