[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1587
  • Last Modified:

Using VB Script to Remove Java v7

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
fadyaz
Asked:
fadyaz
  • 6
  • 2
1 Solution
 
Nagendra Pratap SinghCommented:
So you want to merge these?
0
 
fadyazAuthor Commented:
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
 
Nagendra Pratap SinghCommented:
But your bat file already call the .vbs

call cscript %~dp0\JRERemove.vbs


Does it not work?
0
A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

 
fadyazAuthor Commented:
In which names i should save the files ?? and should they be in same folder ?
0
 
fadyazAuthor Commented:
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
 
fadyazAuthor Commented:
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
 
fadyazAuthor Commented:
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
 
fadyazAuthor Commented:
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

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now