Jump to content

Java auto update


lago
 Share

Recommended Posts

This script is generic for all Java versions. Check last Java version in Java site and local installed, uninstall old versions, download the new and install.
 
I used this UDFs: _RegSearch and _RegFunc

#RequireAdmin
#NoTrayIcon
#include <_RegSearch.au3>
#include <Array.au3>

$Temp = @TempDir & "/" & Random(11111111, 99999999, 1) & ".tmp"
$Title = "Java Auto Update"
;; Check Java remote last version
If Not InetGet("http://javadl-esd.sun.com/update/1.7.0/map-m-1.7.0.xml", $Temp, 7, 0) Then
    MsgBox(48, $Title, "Falha na conexão com a internet")
    Exit
EndIf
$Data = FileRead($Temp)
$Data = StringMid($Data, StringInStr($Data, "<url>", 0, -1) + 5, StringInStr($Data, "</url>", 0, -1) - StringInStr($Data, "<url>", 0, -1) - 5)
InetGet($Data, $Temp, 7, 0)
$Data = FileRead($Temp)
FileDelete($Temp)

$RemoteVersion = StringMid($Data, StringInStr($Data, "<Version>", 0, -1) + 9, StringInStr($Data, "</Version>", 0, -1) - StringInStr($Data, "<Version>", 0, -1) - 9)
$RemoteVersion = StringLeft($RemoteVersion, StringInStr($RemoteVersion, "-", 0, -1) - 1)
$Exe = StringMid($Data, StringInStr($Data, "<url>", 0, -1) + 5, StringInStr($Data, "</url>", 0, -1) - StringInStr($Data, "<url>", 0, -1) - 5)

;; Check Java local version(s)
Local $JavaInReg[1]
$JavaInReg[0] = 0

;; Find Java in registry
$JavaAll = _RegSearchValue("http???java?com*", "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", 1, 1)
If Not @error Then
    For $i = 1 To $JavaAll[0][0]
        $a = $JavaInReg[0] + 1
        If StringCompare($JavaAll[$i][0], $JavaInReg[$JavaInReg[0]]) Then
            _ArrayAdd($JavaInReg, $JavaAll[$i][0])
            $JavaInReg[0] = $JavaInReg[0] + 1
        EndIf
    Next
EndIf

$JavaAll = _RegSearchValue("http???java?com*", "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall", 1, 1)
If Not @error Then
    For $i = 1 To $JavaAll[0][0]
        If StringCompare($JavaAll[$i][0], $JavaInReg[$JavaInReg[0]]) Then
            _ArrayAdd($JavaInReg, $JavaAll[$i][0])
            $JavaInReg[0] = $JavaInReg[0] + 1
        EndIf
    Next
EndIf

;; Get version name
$Installed = ""
For $i = 1 To $JavaInReg[0]
    $Reg = RegRead($JavaInReg[$i], "InstallSource")
    If $Installed = "" Then
        $Installed = StringMid($Reg, StringInStr($Reg, "jre") + 3, StringLen($Reg) - StringInStr($Reg, "jre") - 3)
    Else
        $Installed = $Installed & " | " & StringMid($Reg, StringInStr($Reg, "jre") + 3, StringLen($Reg) - StringInStr($Reg, "jre") - 3)
    EndIf
Next

;; Compare remote vs local
Select
    ;If have no local java
    Case $JavaInReg[0] = 0
        If MsgBox(32 + 1, $Title, "Ultima versão: " & $RemoteVersion & @CRLF & "Nenhuma versão do Java instalado" & @CRLF & @CRLF & "Continuar a instalação?") Then
            MsgBox(64, $Title, "Aguarde o fim da instalação." & @CRLF & @CRLF & "Isto pode levar alguns minutos...")
            JavaInstall()
        EndIf
        Exit
    Case $JavaInReg[0] > 0
        ;If have one local java
        If $RemoteVersion = $Installed Then ; Already updated!
            MsgBox(64, $Title, "    Ultima versão: " & $RemoteVersion & @CRLF & "Versão instalada: " & $Installed & @CRLF & @CRLF & "Seu Java está atualizado!                ")
            Exit
        EndIf
        ;If have one or more local java
        If MsgBox(32 + 1, $Title, "    Ultima versão: " & $RemoteVersion & @CRLF & "Versão instalada: " & $Installed & @CRLF & @CRLF & "Continuar a instalação?") = 1 Then
            MsgBox(64, $Title, "Aguarde o fim da instalação." & @CRLF & @CRLF & "Isto pode levar alguns minutos...")
            JavaUninstall()
            JavaInstall()
        EndIf
        Exit
    Case Else
        MsgBox(0, "", "!")

EndSelect

Func JavaInstall()
    If InetGet($Exe, @TempDir & "\java.exe", 7, 0) Then
        RunWait(@TempDir & "\java.exe /s")
        FileDelete(@TempDir & "\java.exe")
        MsgBox(64, $Title, "Java atualizado!")
        Exit
    Else
        MsgBox(64, $Title, "Falha no download do arquivos" & @CRLF & $Exe)
        Exit
    EndIf
EndFunc   ;==>JavaInstall

Func JavaUninstall()
    For $i = 1 To $JavaInReg[0]
        $Reg = RegRead($JavaInReg[$i], "UninstallString")
        RunWait($Reg & " /qn")
        Sleep(1000)
    Next
EndFunc   ;==>JavaUninstall

Code update: >post #3

Edited by lago
Link to comment
Share on other sites

I had already thought to made a java updater, but I always postponed it later.

Thanks to share yours.

Is an English version possible ?

And when the last version is the same as installed version why ask for continue install ?

Why not use the "_VersionCompare" function ?

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I had already thought to made a java updater, but I always postponed it later.

Thanks to share yours.

Is an English version possible ?

And when the last version is the same as installed version why ask for continue install ?

Why not use the "_VersionCompare" function ?

 

hank you for reply, wakillon!
 
In some computers on my corp, i need to Java is updated to run Banks websites. 
 
I translated the messages into English and fixed the ask. Regarding _VersionCompare, I think that as I'm checking the latest version onlilne, simply if different is not the last installed.
 
Java could be many version installed. I need remove all and install only the last.
 
#RequireAdmin
#include <_RegSearch.au3>
#include <Array.au3>

Dim $Installed, $Data, $RemoteVersion, $Exe = ""
Dim $JavaInReg[1] = [0]
Dim $Temp = @TempDir & "/" & Random(11111111, 99999999, 1) & ".tmp"
Dim $Title = "Java Auto Update"

;; Check Java remote last version
HttpSetProxy(0)
If Not InetGet("http://javadl-esd.sun.com/update/1.7.0/map-m-1.7.0.xml", $Temp, 7, 0) Then
    MsgBox(48, $Title, "Internet connection fail")
    Exit
EndIf
$Data = FileRead($Temp)
$Data = StringMid($Data, StringInStr($Data, "<url>", 0, -1) + 5, StringInStr($Data, "</url>", 0, -1) - StringInStr($Data, "<url>", 0, -1) - 5)
$Data = StringReplace($Data, "https", "http", 1)
If Not InetGet($Data, $Temp, 7, 0) Then
    MsgBox(48, $Title, "Error to download file " & @CRLF & $Data & @CRLF & @CRLF & InetGetInfo(InetGet($Data, $Temp, 7, 0)))
    Exit
EndIf
$Data = FileRead($Temp)
FileDelete($Temp)

$RemoteVersion = StringMid($Data, StringInStr($Data, "<Version>", 0, -1) + 9, StringInStr($Data, "</Version>", 0, -1) - StringInStr($Data, "<Version>", 0, -1) - 9)
$RemoteVersion = StringLeft($RemoteVersion, StringInStr($RemoteVersion, "-", 0, -1) - 1)
$Exe = StringMid($Data, StringInStr($Data, "<url>", 0, -1) + 5, StringInStr($Data, "</url>", 0, -1) - StringInStr($Data, "<url>", 0, -1) - 5)

;; Find Java in registry
$JavaAll = _RegSearchValue("http???java?com*", "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", 1, 1)
If Not @error Then
    For $i = 1 To $JavaAll[0][0]
        $a = $JavaInReg[0] + 1
        If _ArraySearch($JavaInReg, StringMid(RegRead($JavaAll[$i][0], "UninstallString"), 17, 35), 0, 0, 0, 1) < 0 Then
            _ArrayAdd($JavaInReg, $JavaAll[$i][0])
            $JavaInReg[0] = $JavaInReg[0] + 1
        EndIf
    Next
EndIf

$JavaAll = _RegSearchValue("http???java?com*", "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall", 1, 1)
If Not @error Then
    For $i = 1 To $JavaAll[0][0]
        If _ArraySearch($JavaInReg, StringMid(RegRead($JavaAll[$i][0], "UninstallString"), 17, 35), 0, 0, 0, 1) < 0 Then
            _ArrayAdd($JavaInReg, $JavaAll[$i][0])
            $JavaInReg[0] = $JavaInReg[0] + 1
        EndIf
    Next
EndIf

;; Get version name
For $i = 1 To $JavaInReg[0]
    $Reg = RegRead($JavaInReg[$i], "InstallSource")
    If $Installed = "" Then
        $Installed = StringMid($Reg, StringInStr($Reg, "jre") + 3, StringLen($Reg) - StringInStr($Reg, "jre") - 3)
    Else
        $Installed = $Installed & " | " & StringMid($Reg, StringInStr($Reg, "jre") + 3, StringLen($Reg) - StringInStr($Reg, "jre") - 3)
    EndIf
Next

;; Compare remote vs local
Select
    ;If have no local java
    Case $JavaInReg[0] = 0
        If MsgBox(32 + 1, $Title, "Last version: " & $RemoteVersion & @CRLF & "No version of Java installed" & @CRLF & @CRLF & "Continue?") = 1 Then
            MsgBox(64, $Title, "Installation may take a few minutes. Please wait.", 4)
            JavaInstall()
        EndIf
        Exit
    Case $JavaInReg[0] > 0
        ;If have one local java
        If $RemoteVersion = $Installed Then ; Already updated!
            MsgBox(64, $Title, "Last version: " & $RemoteVersion & @CRLF & "Installed version: " & $Installed & @CRLF & @CRLF & "Java already uptodated!")
            Exit
        EndIf
        ;If have one or more local java
        If MsgBox(32 + 1, $Title, "Last version: " & $RemoteVersion & @CRLF & "Installed version: " & $Installed & @CRLF & @CRLF & "Continue?") = 1 Then
            MsgBox(64, $Title, "Installation may take a few minutes. Please wait.", 4)
            JavaUninstall()
            JavaInstall()
        EndIf
        Exit
    Case Else
        MsgBox(0, "", "!")
EndSelect

Func JavaInstall()
    TrayTip($Title, "Downloading Java", 3)
    If InetGet($Exe, @TempDir & "\java.exe", 7, 0) Then
        TrayTip($Title, "Installing, wait...", 3)
        RunWait(@TempDir & "\java.exe /s")
        FileDelete(@TempDir & "\java.exe")
        MsgBox(64, $Title, "Java updated!")
        Exit
    Else
        MsgBox(64, $Title, "Internet connection fail" & @CRLF & $Exe)
        Exit
    EndIf
EndFunc   ;==>JavaInstall

Func JavaUninstall()
    TrayTip($Title, "Uninstalling old versions of Java", 3)
    For $i = 1 To $JavaInReg[0]
        $Reg = RegRead($JavaInReg[$i], "UninstallString")
        RunWait($Reg & " /qn")
        Sleep(1000)
    Next
EndFunc   ;==>JavaUninstall
Edited by lago
Link to comment
Share on other sites

Yes It's better now!

Another remark : Url you use for get the last version can change regarding of number version : http://javadl-esd.sun.com/update/1.7.0/map-m-1.7.0.xml

Java 7 :=> 1.7.0_0x

When java 8.0 will be able, url will change  

Java 8 :=> 1.8.0_0x

So your updater will not work...

Why not use this one : http://www.java.com/en/download/manual.jsp

and so extract "Recommended Version 7 Update 25" and deduce : http://javadl-esd.sun.com/update/1.7.0/map-m-1.7.0.xml

:)

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Hi,
 
here's a possible way to "detect" a recommended version:
 

#include <File.au3>


Local Const $iJAVARecommendedVersion = _JAVA_GetRecommendedVersion()
ConsoleWrite("_JAVA_GetRecommendedVersion() -> [" & @error & "][" & @extended & "][" & $iJAVARecommendedVersion & "]" & @CRLF)


Func _JAVA_GetRecommendedVersion()
    Local Const $sTempFile = _TempFile()
    Local $iError = 0
    Local $iUpdate = 0
    Local $iVersion = 0
    Local $hDownload = InetGet("http://www.java.com/en/download/manual.jsp", $sTempFile, 1, 1)
    If Not @error Then
        Do
            Sleep(250)
        Until InetGetInfo($hDownload, 2)
        If InetGetInfo($hDownload, 3) Then
            Local Const $sFileRead = FileRead($sTempFile)
            $iVersion = StringInStr($sFileRead, "Recommended Version ")
            If Not @error Then
                $iVersion = Int(StringMid($sFileRead, $iVersion + 20, 1))
                Switch $iVersion
                    Case 7, 8
                        $iUpdate = StringInStr($sFileRead, "Recommended Version " & $iVersion & " Update ")
                        If Not @error Then
                            $iUpdate = Int(StringMid($sFileRead, $iUpdate + StringLen("Recommended Version " & $iVersion & " Update "), 2))
                        Else
                            $iError = -1
                        EndIf
                    Case Else
                        $iError = 4
                EndSwitch
            Else
                $iError = 3
            EndIf
        Else
            $iError = 2
        EndIf
        InetClose($hDownload)
    Else
        $iError = 1
    EndIf
    Return SetError($iError, $iUpdate, $iVersion)
EndFunc   ;==>_JAVA_GetRecommendedVersion

Maybe the code is good enough to "detect" upcoming releases...

Greets,
-supersonic.

Edited by supersonic
Link to comment
Share on other sites

In order to proceed you should determine the currently installed Java version (e. g. [HKLM(64)SOFTWAREJavaSoftJava Runtime Environment<Java7FamilyVersion>] and compare it against http://javadl-esd.sun.com/update/1.7.0/map-m-1.7.0.xml to meet a potentially existing update/upgrade path:

<mapping><version>1.7.0_21</version><url>https://javadl-esd-secure.oracle.com/update/1.7.0/au-descriptor-1.7.0_25-b17.xml</url></mapping>
Link to comment
Share on other sites

Here's my approach of detecting a JRE update/upgrade path. Due to the fact that XML files are involved in this script I prefer XML parsing rather than using any raw string processing:

; [http://www.autoitscript.com/forum/topic/152125-java-auto-update/].


#RequireAdmin
;~ #NoTrayIcon


#include <Array.au3>
#include <File.au3>
#include ".\_XMLDomWrapper.au3"


AutoItSetOption("MustDeclareVars", 1) ; Opt()


Local Const $aJRERecommendedVersion = _JRE_GetRecommendedVersion("http://www.java.com/en/download/manual.jsp")
If Not @error Then
    Local Const $sJREAUDescriptorXML = _JRE_GetAUDescriptorXML("http://javadl-esd.sun.com/update/1." & $aJRERecommendedVersion[0] & ".0/map-m-1." & $aJRERecommendedVersion[0] & ".0.xml") ; [http://javadl-esd.sun.com/update/1.7.0/map-m-1.7.0.xml].
;~  Local Const $sJREAUDescriptorXML = _JRE_GetAUDescriptorXML("http://javadl-esd.sun.com/update/1." & $aJRERecommendedVersion[0] & ".0/map-m-1." & $aJRERecommendedVersion[0] & ".0.xml", False, "1.7.0_21")
    Switch @error
        Case 0
            Local Const $aJREAUDescriptors = _JRE_ParseAUDescriptorXML($sJREAUDescriptorXML)
            If Not @error Then
                _ArrayDisplay($aJREAUDescriptors, "[" & _ArrayToString($aJRERecommendedVersion, "][") & "][" & $sJREAUDescriptorXML & "]")
            Else
                MsgBox(0, "", "ERROR (#3)!")
            EndIf
        Case -1
            MsgBox(0, "", "A JRE is not yet installed.")
        Case -2
            MsgBox(0, "", "A JRE update/upgrade is not (yet) available (Version " & $aJRERecommendedVersion[0] & " Update " & $aJRERecommendedVersion[1] & ").")
        Case Else
            MsgBox(0, "", "ERROR (#2)!")
    EndSwitch
Else
    MsgBox(0, "", "ERROR (#1)!")
EndIf


Func _JRE_GetAUDescriptorXML(Const $sURL, Const $bX64 = False, Const $sFamilyVersionOverwrite = "")
    Local $aRecommendedVersion[2] = [0, 0] ; [0] = version, [1] = update.
    Local $iError = 0
    Local $iExtended = 0
    Local $sAUDescriptorXML = ""
    Local Const $sTempFile = _JRE_InetGet($sURL)
    If Not @error Then
        Local $hXML = _XMLFileOpen($sTempFile)
        If Not @error Then
            Local Const $aVersion = _XMLGetValue("//version")
            If Not @error Then
                Local $sX64 = ""
                Switch $bX64
                    Case True
                        $sX64 = "64"
                        ContinueCase ; !!!
                    Case Else
                        Local $sFamilyVersion = ""
                        If $sFamilyVersionOverwrite <> "" Then
                            $sFamilyVersion = $sFamilyVersionOverwrite
                        Else
                            $sFamilyVersion = RegRead("HKLM" & $sX64 & "\SOFTWARE\JavaSoft\Java Runtime Environment", "Java7FamilyVersion")
                        EndIf
                        If Not @error Then
                            Local Const $iFamilyVersion = _ArraySearch($aVersion, $sFamilyVersion, 1)
                            If Not @error Then
                                Local Const $aURL = _XMLGetValue("//mapping[" & $iFamilyVersion & "]/url")
                                If UBound($aURL) - 1 = 1 Then ; If Not @error Then
                                    $sAUDescriptorXML = $aURL[1]
                                Else
                                    $iError = 4
                                    $iExtended = @error
                                EndIf
                            Else ; In case a JRE update/upgrade is not (yet) available.
                                $iError = -2
                                $iExtended = @error
                            EndIf
                        Else ; In case a JRE is not yet installed.
                            $iError = -1
                            $iExtended = @error
                        EndIf
                EndSwitch
            Else
                $iError = 3
                $iExtended = @error
            EndIf
        Else
            $iError = 2
            $iExtended = @error
        EndIf
        $hXML = 0
        FileDelete($sTempFile) ; Purging.
    Else
        $iError = 1
        $iExtended = @error
    EndIf
    Return SetError($iError, $iExtended, $sAUDescriptorXML)
EndFunc   ;==>_JRE_GetAUDescriptorXML


Func _JRE_GetRecommendedVersion(Const $sURL)
    Local $aRecommendedVersion[2] = [0, 0] ; [0] = version, [1] = update.
    Local $iError = 0
    Local $iExtended = 0
    Local $sTempFile = _JRE_InetGet($sURL)
    If Not @error Then
        $sTempFile = FileRead($sTempFile)
        If $sTempFile <> "" Then
            Local $sStringInStr = "Recommended Version "
            Local $iStringInStr = StringInStr($sTempFile, $sStringInStr)
            If Not @error Then
                $aRecommendedVersion[0] = Int(StringMid($sTempFile, $iStringInStr + StringLen($sStringInStr), 1))
                Switch $aRecommendedVersion[0]
                    Case 7, 8
                        $sStringInStr = "Recommended Version " & $aRecommendedVersion[0] & " Update "
                        $iStringInStr = StringInStr($sTempFile, $sStringInStr)
                        If Not @error Then
                            $aRecommendedVersion[1] = Int(StringMid($sTempFile, $iStringInStr + StringLen($sStringInStr), 2))
                        Else ; In case an update is unavailable or undetectable.
                            $iError = -1
                            $iExtended = $aRecommendedVersion[1]
                        EndIf
                    Case Else
                        $iError = 4
                        $iExtended = $aRecommendedVersion[0]
                EndSwitch
            Else
                $iError = 3
                $iExtended = @error
            EndIf
        Else
            $iError = 2
            $iExtended = 0
        EndIf
        FileDelete($sTempFile) ; Purging.
    Else
        $iError = 1
        $iExtended = @error
    EndIf
    Return SetError($iError, $iExtended, $aRecommendedVersion)
EndFunc   ;==>_JRE_GetRecommendedVersion


Func _JRE_InetGet(Const $sURL)
    Local $iError = 0, $iExtended = 0, $sReturn = ""
    If $sURL <> "" Then
        Local Const $sTempFile = _TempFile()
        Local $hDownload = InetGet($sURL, $sTempFile, 1, 1)
        If Not @error Then
            Do
                Sleep(250)
            Until InetGetInfo($hDownload, 2)
            If InetGetInfo($hDownload, 3) Then
                $sReturn = $sTempFile
            Else
                $iError = 3
                $iExtended = 0
            EndIf
            InetClose($hDownload)
        Else
            $iError = 2
            $iExtended = 0
        EndIf
    Else
        $iError = 1
        $iExtended = 0
    EndIf
    Return SetError($iError, $iExtended, $sReturn)
EndFunc   ;==>_JRE_InetGet


Func _JRE_ParseAUDescriptorXML(Const $sURL)
    Local $aAUDescriptors[14][2] = _ ; Case-sensitive.
            [["caption", ""], _
            ["title", ""], _
            ["description", ""], _
            ["moreinfo", ""], _
            ["AlertTitle", ""], _
            ["AlertText", ""], _
            ["moreinfotxt", ""], _
            ["url", ""], _
            ["version", ""], _
            ["post-status", ""], _
            ["cntry-lookup", ""], _
            ["predownload", ""], _
            ["options", ""], _
            ["urlinfo", ""]]
    Local $iError = 0
    Local $iExtended = 0
    Local Const $sTempFile = _JRE_InetGet($sURL)
    If Not @error Then
        Local $hXML = _XMLFileOpen($sTempFile)
        If Not @error Then
            Local $iAUDescriptors = 0
            Local $sOSLanguage = ""
            ; ----------------------------------------------------------------------------------------------------
            ; [http://msdn.microsoft.com/en-us/library/cc233965.aspx], [http://msdn.microsoft.com/en-us/library/ms533052(VS.85).aspx].
            Switch Execute("0x" & @OSLang)
                Case _ ; Chinese (Taiwan).
                        0x0404
                    $sOSLanguage = "zh_TW"
                Case _ ; Chinese (Standard, [...]).
                        0x0004, 0x0804, 0x0c04, 0x1004, 0x1404, 0x7804, 0x7c04
                    $sOSLanguage = "zh"
                Case _ ; German (Standard, [...]).
                        0x0007, 0x0407, 0x0807, 0x0c07, 0x1007, 0x1407
                    $sOSLanguage = "de"
                Case _ ; Spanish (Standard, [...]).
                        0x000a, 0x040a, 0x080a, 0x0c0a, 0x100a, 0x140a, 0x180a, 0x1c0a, 0x200a, 0x240a, 0x280a, 0x2c0a, 0x300a, 0x340a, 0x380a, 0x3c0a, 0x400a, 0x440a, 0x480a, 0x4c0a, 0x500a, 0x540a
                    $sOSLanguage = "es"
                Case _ ; French (Standard, [...]).
                        0x000c, 0x040c, 0x080c, 0x0c0c, 0x100c, 0x140c, 0x180c
                    $sOSLanguage = "fr"
                Case _ ; Italian (Standard, Italy, Switzerland).
                        0x0010, 0x0410, 0x0810
                    $sOSLanguage = "it"
                Case _ ; Japanese (Standard, Japan).
                        0x0011, 0x0411
                    $sOSLanguage = "ja"
                Case _ ; Korean (Standard, Korea).
                        0x0012, 0x0412
                    $sOSLanguage = "ko"
                Case _ ; Portuguese (Standard, Brazil, Portugal).
                        0x0016, 0x0416, 0x0816
                    $sOSLanguage = "pt_BR"
                Case _ ; Swedish (Standard, Sweden, Finland).
                        0x001d, 0x041d, 0x081d
                    $sOSLanguage = "sv"
            EndSwitch
            ; ----------------------------------------------------------------------------------------------------
            Local $aValue[1] = [0]
            Local Const $sXPath = "//information[@xml:lang='" & $sOSLanguage & "']"
            For $i = 0 To UBound($aAUDescriptors, 1) - 1
                _XMLNodeExists($sXPath & "/" & $aAUDescriptors[$i][0])
                If Not @error Then ; Optional.
                    $aValue = _XMLGetValue($sXPath & "/" & $aAUDescriptors[$i][0])
                Else ; Default.
                    $aValue = _XMLGetValue("//information[@xml:lang='en']/" & $aAUDescriptors[$i][0]) ; '@OSLang' = 0x0009, 0x0409, 0x0809, 0x0c09, 0x1009, 0x1409, 0x1809, 0x1c09, 0x2009, 0x2409, 0x2809, 0x2c09, 0x3009, 0x3409, 0x4009, 0x4409, 0x4809.
                EndIf
                If UBound($aValue) - 1 = 1 Then ; If Not @error Then
                    $aAUDescriptors[$i][1] = $aValue[1]
                    $iAUDescriptors += 1
                EndIf
            Next
            If UBound($aAUDescriptors, 1) <> $iAUDescriptors Then
                $iError = 4
                $iExtended = @error
            EndIf
        Else
            $iError = 3
            $iExtended = @error
        EndIf
        $hXML = 0
        FileDelete($sTempFile) ; Purging.
    Else
        $iError = 1
        $iExtended = @error
    EndIf
    Return SetError($iError, $iExtended, $aAUDescriptors)
EndFunc   ;==>_JRE_ParseAUDescriptorXML

You will need "._XMLDomWrapper.au3" attached to this post - this is quite an old version...

Currently this script will only work with the JRE X86 version - maybe others could help to make it work with the X64 version as well...

_XMLDomWrapper.au3

Edited by supersonic
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...