Solved

Using VB Script to Remove Java v7

Posted on 2013-02-04
8
1,530 Views
Last Modified: 2013-02-14
Hello,

I need a script to remove the Java v7 from all machines on our network through the Group Policy . i searched through the internet and i found to scripts on batch file and the other vb script i need your help to modify the script to remove the java versions on all machines.


The Script Has Two Parts.

1. Batch script executed to kill processes then runs the VB script.
2. VB script uninstalls all versions of JRE then resumes the next step of the batch script

1- Batch Script
@echo off
cd\
cls

@ECHO Version 1.0
@ECHO Uninstall of All JRE Versions And Installation Of JRE6U29

@ECHO Authors: Nainesh Bhavan & Dylan Ogle November 2011

:KillIE&JavaProcesses
echo *** This will kill IE and Java Processes ***
Rem ***
taskkill /F /IM iexplorer.exe
taskkill /F /IM iexplore.exe
taskkill /F /IM javaw.exe
taskkill /F /IM jqs.exe
taskkill /F /IM jusched.exe

:UninstallingOldJREVersions
cd\
cls
echo *** This will uninstall older versions of JRE ***
Rem ***
call cscript %~dp0\JRERemove.vbs

:Backup&ClearRegistryForJavaSoft
start /w regedit /e "%systemroot%\JavaSoftRegBackup.reg" HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft /f

:InstallJREVersion29
cd\
cls
echo *** This installs Java 6 Update 29  ***
Rem ***
ver | find "XP" > nul
if %ERRORLEVEL% == 0 start /w %~dp0\MSJavx86.exe /c:"javatrig.exe /exe_install /l /q /qq" /q:a 

/r:n
%~dp0\jre-6u29-windows-i586-s.exe /s /v"AgreeToLicense=YES IEXPLORER=0 MOZILLA=0 REBOOT=SUPRESS 

JAVAUPDATE=0"

:Copying Configuration Properties Files
cd\
cls
echo *** This creates a backup of current JVM.DLL ini JINIT folders ***
Rem ***
if not exist "C:\Windows\Sun\Java\Deployment" MD "C:\Windows\Sun\Java\Deployment"
copy %~dp0\deployment.config "C:\Windows\Sun\Java\Deployment" /y
copy %~dp0\deployment.properties "C:\Windows\Sun\Java\Deployment" /y

:BackupDLL
cd\
cls
echo *** This creates a backup of current JVM.DLL ini JINIT folders ***
Rem ***
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\hotspot\jvm.dll" ren "C:\Program 

Files\Oracle\JInitiator 1.3.1.18\bin\hotspot\jvm.dll" jvm.dll-old
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.22\bin\hotspot\jvm.dll" ren "C:\Program 

Files\Oracle\JInitiator 1.3.1.22\bin\hotspot\jvm.dll" jvm.dll-old
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.26\bin\hotspot\jvm.dll" ren "C:\Program 

Files\Oracle\JInitiator 1.3.1.26\bin\hotspot\jvm.dll" jvm.dll-old
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.28\bin\hotspot\jvm.dll" ren "C:\Program 

Files\Oracle\JInitiator 1.3.1.28\bin\hotspot\jvm.dll" jvm.dll-old

:CopyDLL
cd\
cls
echo *** Copying JVM.DLL File JINIT Folders ***
Rem ***
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\hotspot\jvm.dll-old" copy %~dp0\Fix

\jvm.dll "C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\hotspot\"
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.22\bin\hotspot\jvm.dll-old" copy %~dp0\Fix

\jvm.dll "C:\Program Files\Oracle\JInitiator 1.3.1.22\bin\hotspot\"
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.26\bin\hotspot\jvm.dll-old" copy %~dp0\Fix

\jvm.dll "C:\Program Files\Oracle\JInitiator 1.3.1.26\bin\hotspot\"
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.28\bin\hotspot\jvm.dll-old" copy %~dp0\Fix

\jvm.dll "C:\Program Files\Oracle\JInitiator 1.3.1.28\bin\hotspot\"

:DisableJavaPlugin
cd\
cls
echo *** This will disable next generation Java Plugin in Control Panel
Rem ***
regedit.exe -s %~dp0\DisableJavaPlugin.reg


:DisableJavaAutoUpdate
cd\
cls
echo *** This will disable next generation Java Plugin in Control Panel
Rem ***
REG.EXE ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v EnableJavaUpdate /t REG_DWORD /d 0 /f
REG.EXE ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v EnableAutoUpdateCheck /t REG_DWORD /d 

0 /f
REG.EXE ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v NotifyDownload /t REG_DWORD /d 0 /f
REG.EXE ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v NotifyInstall /t REG_DWORD /d 0 /f
REG.EXE DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v SunJavaUpdateSched /f

Open in new window


2- VB Uninstall Script. Simple and Elegant :)

'###########Script Written By Dylan Ogle & Nainesh Bhavan - November 2011##########

'Start Script

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Uninstall Java 2 Runtime Environment, J2SE Runtime Environment
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java 2 Runtime Environment Standard Edition %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next


'Uninstall Java 2 Runtime Environment, J2SE Runtime Environment
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'J2SE Runtime Environment %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next

'Uninstall Java 2 Runtime Environment, SE *
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java 2 Runtime Environment, SE %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 6 Update *
Set colJava6dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 6 Update %'")
For Each objSoftware in colJava6dot
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 7 Update *
Set colJava6dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 7 Update %'")
For Each objSoftware in colJava6dot
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 7 *
Set colJava7 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) %'")
For Each objSoftware in colJava7
objSoftware.Uninstall()
Next

Open in new window



Thanks & regards,
0
Comment
Question by:fadyaz
  • 6
  • 2
8 Comments
 
LVL 23

Expert Comment

by:Nagendra Pratap Singh
Comment Utility
So you want to merge these?
0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
Hi npsingh123,

I tried the two scripts and they are not working on my PC , i need a help to let the scripts work or any script to remove java from the PCs .

and if you can help me to let them in one script i appreciate it.
0
 
LVL 23

Expert Comment

by:Nagendra Pratap Singh
Comment Utility
But your bat file already call the .vbs

call cscript %~dp0\JRERemove.vbs


Does it not work?
0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
In which names i should save the files ?? and should they be in same folder ?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Author Comment

by:fadyaz
Comment Utility
i made the two files

1- removejava.bat
2- JRERemove.vbs

and i run the removejava.bat abd it called the JRERemove.vbs but the java is still installed on the PC.

Does there is wrong on the files ??
0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
I found this script for removing Java 6

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

'Uninstall Java 2 Runtime Environment, J2SE Runtime Environment
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java 2 Runtime Environment Standard Edition %'")
For Each objSoftware in colJava4dot3
	objSoftware.Uninstall()
Next

'Uninstall Java(TM) 6 Update *
Set colJava6dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 6 Update %'")
For Each objSoftware in colJava6dot
	WScript.Echo "Found " & objSoftware.Name & " v: " & objSoftware.Version
	objSoftware.Uninstall()
Next 

Open in new window


How i can modify it to remove java 7 ?
0
 
LVL 2

Accepted Solution

by:
fadyaz earned 0 total points
Comment Utility
I found a perfect VB script that help to remove java and i run it using this comand
cscript /nologo JavaUninstallScript.vbs /keeponly

Open in new window


the VB Script in the Attachment for your information
JavaUninstallScript.txt
0
 
LVL 2

Author Closing Comment

by:fadyaz
Comment Utility
No body help me in this question. And I searched the internet and i found the attached scrpit and it is working fine and i removed all java on my Organization
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
OfficeMate Freezes on login or does not load after login credentials are input.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now