Solved

Java Deployment

Posted on 2015-01-29
4
126 Views
Last Modified: 2015-02-27
Hi all,

I run a predepoyment task to remove old versions of Java and then deploy the new version as msi
@ECHO OFF
cls
TITLE Uninstalling Java 5-8 and Java fx. . .

wmic product where "name like 'Java 7%%'" call uninstall /nointeractive
wmic product where "name like 'Java 8%%'" call uninstall /nointeractive
wmic product where "name like 'JavaFX%%'" call uninstall /nointeractive
wmic product where "name like 'Java(TM) 7%%'" call uninstall /nointeractive
wmic product where "name like 'Java(tm) 6%%'" call uninstall /nointeractive
wmic product where "name like 'Java(TM) 8%%'" call uninstall /nointeractive
wmic product where "name like 'J2SE Runtime Environment%%'" call uninstall /nointeractive
goto END

:END
exit

Works OK, but on some PC's the computer reboots...not good when the user is engaged with work :)

Anyway to suppress reboots in wmic?
0
Comment
Question by:kwatt562
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 40578741
Hi, you cannot get the Win32_Product class to uninstall with reboot suppression, as it doesn't support any switches.  There can be issues with enumerating the Win32_Product class anyway, so I'd stay away from it.

You would be better to enumerate the registry for any installations of Java, and run their associated UninstallString commands, to which you can add /qn /norestart switches.

The following is a VBS script that you can use to do this.

Regards,

Rob.

On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd /c TASKKILL /IM Java2.exe", 0, True
arrKeys = Array("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall")
Set objRegistry = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\.\root\default:StdRegProv")
For Each strKey In arrKeys
	objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
	If Not IsNull(arrSubKeys) Then
		For Each strSubKey In arrSubKeys
			objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
			objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
			objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "UninstallString", strUninstallString
			If (InStr(1, strDisplayName, "Java", vbTextCompare) Or InStr(1, strDisplayName, "J2SE", vbTextCompare)) And Trim(strUninstallString) <> "" Then
				objShell.Run "cmd /c start /wait ""Java Uninstall"" " & Replace(strUninstallString, "/I", "/X") & " /qn /norestart", 0, True
			End If
			strDisplayName = vbEmpty
			strDisplayVersion = vbEmpty
			strUninstallString = vbEmpty
		Next
	End If
Next

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 40578787
Oh, note that the above script only enumerates the Wow6432Node of the registry, and so only uninstalls 32 bit software.  To search for 64 bit software, remove the Wow6432Node key from that string.

Rob.
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 40635759
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question