Tuesday, November 2, 2010

I was getting tired of some of the problems with the Java core.zip install failure so I came up with this script. It isn't pretty but it does work to install or fix a machine that currently messed up. Test it, use at your own risk

------------------------

'On Error Resume Next
Dim WshShell, strKeyPath
dim filesys, demofolder
set WshShell = WScript.CreateObject("WScript.Shell")
set filesys = CreateObject ("Scripting.FileSystemObject")

Installed=0 ' I haven't installed Java correctly yet
'determine if this is a 64bit machine
Set Wmi = GetObject("winmgmts:\\.\root\CIMV2")
Set Col = Wmi.ExecQuery("SELECT * FROM Win32_Processor")
For Each Obj in Col
MachineType= Obj.AddressWidth
next


'''Install Java Loop
Do Until Installed=1

'Install Java
WshShell.run("msiexec /i jre1.6.0_22.msi /qb IEXPLORER=1 MOZILLA=1 REBOOT=Suppress JAVAUPDATE=0"), 0, True

'check to see if it installed correctly


if filesys.FileExists("c:\Program Files\Java\jre6\Core.zip") then
FixJava(MachineType)
elseif filesys.FileExists("c:\Program Files (x86)\Java\jre6\core.zip") then
FixJava(MachineType)
else
Installed=1
end if
Loop

Sub FixJava(MachineType)


if MachineType=32 then

'''''''''x86 runtime

''delete the registry entries FOR X86

strKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216022FF}\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Web Start\1.6.0_22\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF\SourceList\Net\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF\sourceList\Media\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF\SourceList\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF\"
WshShell.RegDelete strKeyPath

set demofolder = filesys.GetFolder("Program Files\Java\")
demofolder.Delete


end if

if MachineType=64 then
'''''''''''''''x64 runtime
strKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216022FF}\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start\1.6.0_22\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF\SourceList\Net\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF\sourceList\Media\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF\SourceList\"
WshShell.RegDelete strKeyPath

strKeyPath = "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF\"
WshShell.RegDelete strKeyPath

set demofolder = filesys.GetFolder("c:\program files (x86)\java")
demofolder.Delete
End if


End Sub

--------------------