argument list - quick question

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 6 months ago.

  • Author
    Posts
  • #5486

    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
    ERROR
    At C:\software_installations\scripts\auto-install.ps1:19 char:10
    + Throw < <<< "ERROR"
    + CategoryInfo : OperationStopped: (ERROR:String) [], RuntimeExce
    ption
    + FullyQualifiedErrorId : ERROR

    auto-install.ps1
    ——————–
    $installDir = 'C:\software_installations\jdk1.6\'
    $arguments = @(
    '/s',
    '/v/qn',
    ' 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 ?

    Sincerely

    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.
    Thanks

    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: http://www.adminarsenal.com/admin-arsen ... -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',
    $PathFinal,
    [EnvironmentVariableTarget]::Machine)
    }

You must be logged in to reply to this topic.