Skip to content

Instantly share code, notes, and snippets.

@crmckenzie
Created February 10, 2016 22:36
Show Gist options
  • Save crmckenzie/4d8bc2ca257de8999c9e to your computer and use it in GitHub Desktop.
Save crmckenzie/4d8bc2ca257de8999c9e to your computer and use it in GitHub Desktop.
function Install-Java7JRE()
{
# 7.0.79
$url = "http://javadl.sun.com/webapps/download/AutoDL?BundleId=106369"
$filename = "jre-7u79-windows-x64.exe"
$downloadedFile = Join-Path $env:TEMP $filename
$javaHome = Join-Path $env:ProgramFiles "Java\jre7"
$jreForPathVariable = Join-Path $javaHome 'bin'
if ((Test-Path -Path $downloadedFile) -eq $acfalse)
{
Invoke-WebRequest -Uri $url -OutFile $downloadedFile
}
$process = Start-Process -FilePath $downloadedFile `
-ArgumentList /s `
-NoNewWindow -Wait
[Environment]::SetEnvironmentVariable('JAVA_HOME', $javaHome, 'Machine')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment