Author Posts

January 1, 2012 at 12:00 am

by chz013 at 2013-01-29 23:24:39

Hi All

We like to install java on windows silently but we were unsuccessful 🙁

c:\software_installations>powershell.exe -noexit C:\software_installations\scripts\auto-install.ps1
At C:\software_installations\scripts\auto-install.ps1:19 char:10
+ Throw < <<< "ERROR"
+ CategoryInfo : OperationStopped: (ERROR:String) [], RuntimeExce
+ FullyQualifiedErrorId : ERROR

$installDir = 'C:\software_installations\jdk1.6\'
$arguments = @(
' INSTALLDIR=$installDir' ,
'/L \`"C:\software_installations\scripts\auto-install.log\'

$proc = Start-Process "C:\software_installations\jdk-6u37-windows-x64.exe" -ArgumentList $arguments -Wait -PassThru

What are we doing wrong ?


by nohandle at 2013-01-30 00:47:03

\`" this does not seem right you don't need to escape the quote in single-quoted string.
auto-install.log\' on the end of the same line, you do not terminate the quotation.

by chz013 at 2013-01-30 11:22:05

Hi nohandle

Thanks for your reply.
Your suggestion didnt work.

by nohandle at 2013-01-30 11:42:21

Hi, how about this?
$installDir = 'C:\software_installations\jdk1.6\'
$exePath = 'C:\software_installations\jdk-6u37-windows-x64.exe'
$logPath = 'C:\software_installations\scripts\auto-install.log'
invoke-expression "$exePath '/s' '/v' '/qn' 'INSTALLDIR=$installDir' '/L' '$logPath'"

The idea is to create a string in this format
I am not sure if the back slash before the log path is needed.

Experiment with it in the old windows command line until you get a command that works then rewrtire it to this format and it should work.

Here is guide for not so old version of java JRE, it maybe helps you: ... -update-22

by chz013 at 2013-01-30 14:42:46

Hi Jakub

Thanks for responding.
We tried another approach and it works and JAVA_HOME variable is created.
The issue now is getting JAVA_HOME to append to PATH.
We tried

$pathDelimiter = ";"
$jdkPath = [Environment]::GetEnvironmentVariable("JAVA_HOME")
$path = Get-ChildItem Env:path

if (! $path.Value.Contains($jdkPath))
[environment]::SetEnvironmentVariable('JAVA_HOME', $installDir, 'machine')
$jdkPath = [Environment]::GetEnvironmentVariable("JAVA_HOME")
# Append the jdk bin path, prefaced with a path delimiter
[Environment]::SetEnvironmentVariable($path.Name, $jdkPath + "\bin" + $pathDelimiter + $path.Value, "Machine")

But the path variable doesnt seem to get modified.

We also tried
[Environment]::SetEnvironmentVariable($path.Name, $jdkPath.Value + "\bin" + $pathDelimiter + $path.Value, "Machine")

and it didnt help.

Any tips ?

by nohandle at 2013-01-31 00:52:45

How about this?
if ($env:java_home)
$PathFinal = $env:Path + ';' + $env:java_home
[environment]::SetEnvironmentVariable( 'Path',