Solved

Java Deployment

Posted on 2015-01-29
4
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

696 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