PoshCode Archive  Artifact Content

Artifact 1dff260a0ca085257bef840c37c24b386e4a5aa386fd9829ea073ee406d77cbe:

  • File UpdateJava.ps1 — part of check-in [4bbf905c51] at 2018-06-10 13:38:33 on branch trunk — A simple script to download and install Java 7 u 25. Yeah, you could use chocolatey but I don’t want to install it. (user: DoNotNotTouch size: 1423)

# encoding: ascii
# api: powershell
# title: UpdateJava
# description: A simple script to download and install Java 7 u 25. Yeah, you could use chocolatey but I don’t want to install it.
# version: 0.1
# author: DoNotNotTouch
# license: CC0
# x-poshcode-id: 4224
# x-archived: 2016-01-21T17:12:26
# x-published: 2016-06-24T16:42:00
#
#
$sourcex86 = 'http://javadl.sun.com/webapps/download/AutoDL?BundleId=79063' #Java 7 u 25 x86
$sourcex64 = 'http://javadl.sun.com/webapps/download/AutoDL?BundleId=79065' #Java 7 u 25 x64

$64bit = $false
if(Test-Path 'C:\Program Files (x86)' -PathType Container){
    $64bit = $true
}

try{
    if(Test-Path 'C:\Download\Java' -PathType Container){
        $destinationx86 ='C:\Download\Java\java7u25x86.exe'
        if($64bit){
            $destinationx64 ='C:\Download\Java\java7u25x64.exe'
        }
    }
    else{
        New-Item -Path 'C:\Download' -Name 'Java' -ItemType directory
        $destinationx86 ='C:\Download\Java\java7u25x86.exe'
        if($64bit){
            $destinationx64 ='C:\Download\Java\java7u25x64.exe'
        }
    }

    $wc = New-Object System.Net.WebClient
    $wc.DownloadFile($sourcex86, $destinationx86)
    if($64bit){
        $wc.DownloadFile($sourcex64, $destinationx64)
    }
}
catch{
    $Error[0]
    return (-1)
}




CMD /c $destinationx86 /s
if($64bit){
    CMD /c $destinationx64 /s
}