Uninstall old Java Version with VBScript CA
Hi,
I'm trying to uninstall all previous versions of Java before installing the latest 31. I use a VB script custom action to do the same.
The VB Script works fine when I run it outside package. But when I use it as a custom action, the previous versions are not uninstalling.
I verified that custom action runs by inserting message box within VB script. The following code in VB Script has no effect within CA.
objVersion.Uninstall()
Please help!
Part of VB Script
------------------
strCurrentVersion = "Java(TM) 6 Update 31"
strExecQuery = "Select * from Win32_Product Where Name LIKE '%Java 2 Runtime Environment%' OR Name LIKE '%J2SE Runtime Environment%' OR Name LIKE '%Java(TM)%'"
KillProc
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledVersions = objWMIService.ExecQuery (strExecQuery)
LogIt String(120, "_")
LogIt String(120, "¯")
For Each objVersion in colInstalledVersions
If objVersion.Name = strCurrentVersion then
LogIt Now() & ": " &replace(strComputer,".","localhost") & ": Current version is installed: " & objVersion.Name & ":" & objVersion.IdentifyingNumber
else
LogIt Now() & ": " &replace(strComputer,".","localhost") & ": Uninstalling: " & objVersion.Name & ":" & objVersion.IdentifyingNumber
objVersion.Uninstall()
end if
Next
I'm trying to uninstall all previous versions of Java before installing the latest 31. I use a VB script custom action to do the same.
The VB Script works fine when I run it outside package. But when I use it as a custom action, the previous versions are not uninstalling.
I verified that custom action runs by inserting message box within VB script. The following code in VB Script has no effect within CA.
objVersion.Uninstall()
Please help!
Part of VB Script
------------------
strCurrentVersion = "Java(TM) 6 Update 31"
strExecQuery = "Select * from Win32_Product Where Name LIKE '%Java 2 Runtime Environment%' OR Name LIKE '%J2SE Runtime Environment%' OR Name LIKE '%Java(TM)%'"
KillProc
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledVersions = objWMIService.ExecQuery (strExecQuery)
LogIt String(120, "_")
LogIt String(120, "¯")
For Each objVersion in colInstalledVersions
If objVersion.Name = strCurrentVersion then
LogIt Now() & ": " &replace(strComputer,".","localhost") & ": Current version is installed: " & objVersion.Name & ":" & objVersion.IdentifyingNumber
else
LogIt Now() & ": " &replace(strComputer,".","localhost") & ": Uninstalling: " & objVersion.Name & ":" & objVersion.IdentifyingNumber
objVersion.Uninstall()
end if
Next
0 Comments
[ + ] Show comments
Answers (3)
Answer Summary:
Please log in to answer
Posted by:
RonW
12 years ago
Posted by:
anonymous_9363
12 years ago
You don't say whether the script is being run as an embedded VBScript, extracted from the Binary table and executed or run as a file installed as part of the upgrade package. You also fail to tell us what error is logged (I notice the total absence of error-checking in the code...)
Having said that, there is a proven script posted here on AppDeploy. I can't recall if it's in this forum or the 'Scripting' forum.
Having said that, there is a proven script posted here on AppDeploy. I can't recall if it's in this forum or the 'Scripting' forum.
Posted by:
henrik80
12 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.