Skip to content

Instantly share code, notes, and snippets.

@thephilip
Last active October 6, 2016 18:39
Show Gist options
  • Save thephilip/7287099159105d3ef516617ee56690db to your computer and use it in GitHub Desktop.
Save thephilip/7287099159105d3ef516617ee56690db to your computer and use it in GitHub Desktop.
Java JNLP File Association Fix
@echo off
color e9
goto :CHECKPERMS
:RUN
:: Kill all IE processes
taskkill /f /im iexplore.exe /t >nul 2>&1
ping -n 1 127.0.0.1 >nul 2>&1
:: Check system arch
if %processor_architecture% == x86 (
ftype JNLPFile="c:\program files (x86)\java\jre7\bin\javaws.exe" "%1"
assoc .jnlp=JNLPFile
) else (
ftype JNLPFile="c:\program files\java\jre7\bin\javaws.exe" "%1"
assoc .jnlp=JNLPFile
)
:: Clear IE cache, cookies, download history, and tracking protection (respectively)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16384
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2304
:: Clear Java WebStart applications and cache
javaws -uninstall >nul 2>&1
ping -n 1 127.0.0.1 >nul 2>&1
goto :END
:CHECKPERMS
echo Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
goto :RUN
) else (
color 47
echo Please re-run this script with Admin permissions.
pause
goto :END
)
:END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment