[wpkg-users] Deactivate java plugin...

Rainer Meier r.meier at wpkg.org
Sun Jan 13 01:23:50 CET 2013


Hi Cedric,

On 12.01.2013 10:38, Cedric Frayssinet wrote:
> Do you know how to deactivate java plugin from browsers ?

Well in fact it's quite easy for Firefox. You actually just need to remove it 
from registry keys in HKLM\Software\MozillaPlugins\@java.com/*.

Unfortunately for Internet explorer it's much more complex and I even think it 
cannot be done easily by script.


Although I have created a small FirefoxJavaPluginDisable.cmd script which does 
the job for Firefox unattendedly:


################### FirefoxJavaPluginDisable.cmd ########################
@echo off

echo Disabling Firefox Plugin
set REG32=reg.exe
if exist "%SystemRoot%\SysWoW64\reg.exe" set REG32=%SystemRoot%\SysWoW64\reg.exe

setlocal EnableDelayedExpansion
for /F "usebackq" %%K in (`%REG32% query HKLM\Software\MozillaPlugins\ ^| 
findstr /L @java.com`) do (
   set KEY=%%~nxK
   "%REG32%" copy HKLM\Software\MozillaPlugins\@java.com/!KEY! 
HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! /s /f > NUL
   "%REG32%" delete HKLM\Software\MozillaPlugins\@java.com/!KEY! /f > NUL
)

if not exist "%ProgramFiles%\Mozilla Firefox\extensions\" goto skip32bit
for /f "usebackq" %%I in (`dir /b "%ProgramFiles%\Mozilla 
Firefox\extensions\{CAFE*"`) do (
   rd /s /q "%ProgramFiles%\Mozilla Firefox\extensions\%%I" > NUL
)
:skip32bit

if "%ProgramFiles(x86)%" == "" goto skip64Bit
set KEY=
for /F "usebackq" %%K in (`reg query HKLM\Software\MozillaPlugins\ ^| findstr /L 
@java.com`) do (
   set KEY=%%~nxK
   reg copy HKLM\Software\MozillaPlugins\@java.com/!KEY! 
HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! /s /f > NUL
   reg delete HKLM\Software\MozillaPlugins\@java.com/!KEY! /f > NUL
)

if not exist "%ProgramFiles(x86)%\Mozilla Firefox\extensions\" goto skip64bit
for /f "usebackq" %%I in (`dir /b "%ProgramFiles(x86)%\Mozilla 
Firefox\extensions\{CAFE*"`) do (
   rd /s /q "%ProgramFiles(x86)%\Mozilla Firefox\extensions\%%I" > NUL
)

:skip64Bit

endlocal

exit /b 0
################### FirefoxJavaPluginDisable.cmd ########################

Beware of line breaks. You can find a paste here as well:
<http://pastebin.com/pR0B644h>


Also I wrote a script to re-enable it:
################### FirefoxJavaPluginEnable.cmd ########################
@echo off

echo Enabling Firefox Plugin
set REG32=reg.exe
if exist "%SystemRoot%\SysWoW64\reg.exe" set REG32=%SystemRoot%\SysWoW64\reg.exe

setlocal EnableDelayedExpansion
set KEY=
for /F "usebackq" %%K in (`%REG32% query HKLM\Software\MozillaPlugins\disabled 
^| findstr /L @java.com/JavaPlugin`) do (
   set KEY=%%~nxK
)
if "%KEY%" == "" goto skipRestoreJavaPlugin
"%REG32%" copy HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! 
HKLM\Software\MozillaPlugins\@java.com/!KEY! /s /f > NUL
"%REG32%" delete HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! /f > NUL
:skipRestoreJavaPlugin

set KEY=
for /F "usebackq" %%K in (`%REG32% query HKLM\Software\MozillaPlugins\disabled 
^| findstr /L @java.com/DTPlugin`) do (
   set KEY=%%~nxK
)
if "%KEY%" == "" goto skipRestoreDeploymentPlugin
"%REG32%" copy HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! 
HKLM\Software\MozillaPlugins\@java.com/!KEY! /s /f > NUL
"%REG32%" delete HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! /f > NUL
:skipRestoreDeploymentPlugin


if "%ProgramFiles(x86)%" == "" goto skip64Bit
set KEY=
for /F "usebackq" %%K in (`reg query HKLM\Software\MozillaPlugins\disabled ^| 
findstr /L @java.com/JavaPlugin`) do (
   set KEY=%%~nxK
)
if "%KEY%" == "" goto skipRestoreJavaPlugin64
reg copy HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! 
HKLM\Software\MozillaPlugins\@java.com/!KEY! /s /f > NUL
reg delete HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! /f > NUL
:skipRestoreJavaPlugin64

set KEY=
for /F "usebackq" %%K in (`reg query HKLM\Software\MozillaPlugins\disabled ^| 
findstr /L @java.com/DTPlugin`) do (
   set KEY=%%~nxK
)
if "%KEY%" == "" goto skipRestoreDeploymentPlugin64
reg copy HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! 
HKLM\Software\MozillaPlugins\@java.com/!KEY! /s /f > NUL
reg delete HKLM\Software\MozillaPlugins\disabled\@java.com/!KEY! /f > NUL
:skipRestoreDeploymentPlugin64

:skip64Bit

endlocal

exit /b 0
################### FirefoxJavaPluginEnable.cmd ########################

Beware of line breaks. You can find a paste here as well:
<http://pastebin.com/dqED3fmi>


NOTE:
For Java 1.7.0 U10 and newer there is an installer option which disables all 
Java plugins by default:
WEB_JAVA=0

See 
<http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/client-security.html> for 
details.

It's also possible in control panel -> Java -> Security to re-enable Java 
content in browser later on.

I am currently using the WEB_JAVA=0 option to deploy Java without active Java 
Plugin. Still allowing local administrators to re-enable it as needed.

I haven't investigated yet how to toggle the "[ ] Enable Java content in the 
browser" checkbox via script. Maybe it's just a registry setting too.

br,
Rainer



More information about the wpkg-users mailing list