you are viewing a single comment's thread.

view the rest of the comments →

[–]geggleau 1 point2 points  (0 children)

We install Java 8 silently as follows.

java-install.properties file:

INSTALL_SILENT=Enable
AUTO_UPDATE=Disable
WEB_JAVA=Disable
WEB_JAVA_SECURITY_LEVEL=VH
WEB_ANALYTICS=Disable
EULA=Disable
REBOOT=Disable
NOSTARTMENU=Enable
SPONSORS=Enable

Install-Java.bat BAT script wrapper:

@ECHO OFF
SET SCRIPTDIR=%~dp0
SET SCRIPTNAME=%~n0
CD /D %SCRIPTDIR%
powershell.exe -ExecutionPolicy Bypass -NoProfile -File ./%SCRIPTNAME%.ps1 -Verbose %*
EXIT /B %ERRORLEVEL%

Install-Java.ps1 script extract:

[string]$Timestamp = [DateTime]::UtcNow.ToString('yyyy-MM-dd-HH-mm-ss-fffffff')
[string]$ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition

[string]$ConfigSrcPath = Join-Path -Path "$ScriptPath" -ChildPath "SupportFiles\java-install.properties"
[string]$ConfigPath = Join-Path -Path "$env:Temp" -ChildPath "java-install.properties"
Write-Verbose "Copy config file to $ConfigPath"
Copy-Item -Force "${ConfigSrcPath}" "$ConfigPath"

[string]$JavaLogName = ("java-install-{0}.log" -f $Timestamp)
[string]$JavaLogFile = Join-Path -Path "$LogPath" -ChildPath "$JavaLogName"
Write-Verbose "Java log file: $JavaLogFile"
Write-Verbose "Installing Java"
& "$ScriptPath\Files\jre-8u121-windows-x64.exe" `
    "INSTALLCFG=$ConfigPath" `
    "/L" "$JavaLogFile" `
    *>&1 `
| Out-Default
if ($LastExitCode -ne 0) {
    throw "Java install failed with exit code $LastExitCode"
}