'Cleanup Script to Uninstall All Previous Versions of JRE
'On Error Resume Next
Const HKLM = &h80000002
Const SearchValue = "DisplayName"
Const MatchData = "JAVA"
Set objShell = WScript.CreateObject("WScript.Shell")
Set reg = GetObject("winmgmts://./root/default:StdRegProv")
strProgramFiles = objShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%" & "\")
If InStr(strProgramFiles,"%") Then
StartKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
FindAppKey HKLM, StartKey, SearchValue, MatchData
Else
StartKey1 = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
StartKey2 = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
FindAppKey HKLM, StartKey1, SearchValue, MatchData
FindAppKey HKLM, StartKey2, SearchValue, MatchData
End If
Sub FindAppKey(root, key, value, data)
reg.EnumValues HKLM, key, names, types
If Not IsNull(names) Then
For Each name In names
If name = value Then
reg.GetStringValue HKLM, key, name, regdata
strRegData = UCase(regdata)
If InStr(strRegData, data) Then
If InStr(strRegData,"UPDATER") OR InStr(strRegData,"DEVELOPMENT")Then
'Do Nothing
Else
reg.GetStringValue HKLM, key, "UninstallString", strPdtCode
strUninstallString = strPdtCode & " /qn REBOOT=ReallySuppress"
'Msgbox strUninstallString
objShell.Run strUninstallString,0,True
End If
End If
End If
Next
End If
'value not found in current key => continue search in subkeys
reg.EnumKey root, key, subkeys
If Not IsNull(subkeys) Then
For Each sk In subkeys
FindAppKey root, key & "\" & sk, value, data
Next
End If
End Sub
'#### Run seperate command for JAVA Auto Updater Uninstallaton
objShell.Run "msiexec.exe /X{4a03706f-666a-4037-7777-5f2748764d10} /qn REBOOT=ReallySuppress", 0, true
'##### Use Sysnative in Program commandline