@echo off

set LOG_FILE=log\Setup.log

cd /d %~dp0% 

if NOT EXIST log (
	mkdir log
)

echo [%date%-%time%] Start: UnsetWin.bat >> %LOG_FILE%
echo Unset Web Console Launcher
echo Unset Web Console Launcher >> %LOG_FILE%

echo reg QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.jnlp >> %LOG_FILE%
reg QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.jnlp >> %LOG_FILE% 2>&1
IF NOT "%ERRORLEVEL%" == "0" (
GOTO :SKIP
)

echo reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPLauncher\shell\open\command /f  >> %LOG_FILE%
reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPLauncher\shell\open\command /f >> %LOG_FILE% 2>&1
IF NOT "%ERRORLEVEL%" == "0" (
GOTO :ERROR
)

echo reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPLauncher\shell\open /f >> %LOG_FILE%
reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPLauncher\shell\open /f >> %LOG_FILE% 2>&1
IF NOT "%ERRORLEVEL%" == "0" (
GOTO :ERROR
)

echo reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPLauncher\shell /f >> %LOG_FILE%
reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPLauncher\shell /f >> %LOG_FILE% 2>&1
IF NOT "%ERRORLEVEL%" == "0" (
GOTO :ERROR
)

echo reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPLauncher /f >> %LOG_FILE%
reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPLauncher /f >> %LOG_FILE% 2>&1
IF NOT "%ERRORLEVEL%" == "0" (
GOTO :ERROR
)

echo reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.jnlp /f >> %LOG_FILE%
reg DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.jnlp /f >> %LOG_FILE% 2>&1
IF NOT "%ERRORLEVEL%" == "0" (
GOTO :ERROR
)

echo reg DELETE HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jnlp /f >> %LOG_FILE%
reg DELETE HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jnlp /f >> %LOG_FILE% 2>&1

echo reg DELETE "HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/x-java-jnlp-file" /f >> %LOG_FILE%
reg DELETE "HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/x-java-jnlp-file" /f >> %LOG_FILE% 2>&1
IF NOT "%ERRORLEVEL%" == "0" (
GOTO :ERROR
)

echo Completed.
echo Completed. >> %LOG_FILE%
echo [%date%-%time%] End(0): UnsetWin.bat >> %LOG_FILE%
exit /b 0

:ERROR

echo Error: Please run as Administrator.
echo Error: Please run as Administrator. >> %LOG_FILE%
echo [%date%-%time%] End(1): UnsetWin.bat >> %LOG_FILE%
exit /b 1

:SKIP

echo Skipped: Web Console Launcher is not settle.
echo Skipped: Web Console Launcher is not settle. >> %LOG_FILE%
echo [%date%-%time%] End(0): UnsetWin.bat >> %LOG_FILE%
exit /b 0