REM Check Windows Version
ver | findstr /i "5\.0\." > nul
if %ERRORLEVEL% EQU 0 goto ver_2000
ver | findstr /i "5\.1\." > nul
if %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "5\.2\." > nul
if %ERRORLEVEL% EQU 0 goto ver_2003
ver | findstr /i "6\.0\." > nul
if %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." > nul
if %ERRORLEVEL% EQU 0 goto ver_Win7
ver | findstr /i "6\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Win7
:ver_2000
echo 2000
goto runL2
:ver_XP
echo xp
goto runL2
:ver_2003
echo 2003
goto runL2
:runL2
SET L2DIR=%~dp0
ECHO Current directory: %L2DIR%
if not exist "%L2DIR%\l2.exe" goto ERR2
START /MIN l2.exe
goto END
:ver_Vista
echo Vista
goto BatchGotAdmin
:ver_Win7
echo Windows7
goto BatchGotAdmin
:BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges, please wait...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
if exist "%SystemRoot%\SysWOW64\cmd.exe" SET SYSDIR="%SystemRoot%\SysWOW64"
goto STEP0
SET SYSDIR="%SystemRoot%\System32"
:STEP0
SET L2DIR=%~dp0
ECHO Current directory: %L2DIR%
if not exist "%L2DIR%\l2.exe" goto ERR2
CD SYSTEM
if not exist "%SYSDIR%\rsaenh.dll" goto ERR3
if exist ".\rsaenh.dll.bak" goto STEP1
takeown /f "%SYSDIR%\rsaenh.dll"
icacls "%SYSDIR%\rsaenh.dll" /grant %USERNAME%:F
move /Y "%SYSDIR%\rsaenh.dll" "%SYSDIR%\rsaenh.dll.bak"
if not exist "%SYSDIR%\rsaenh.dll.bak" goto ERR4
:--------------------------------------
:STEP1
if exist "%SYSDIR%\rsaenh.dll" del "%SYSDIR%\rsaenh.dll"
:CRTWAIT
if exist waitl2run.bat del waitl2run.bat
:: Waiting 10 seconds and moving rsaenh.dll back to SYSTEM folder.
echo @echo off>waitl2run.bat
echo cls>>waitl2run.bat
echo TIMEOUT /T 10>>waitl2run.bat
echo move /Y "%SYSDIR%\rsaenh.dll.bak" "%SYSDIR%\rsaenh.dll">>waitl2run.bat
echo EXIT>>waitl2run.bat
START /MIN %L2DIR%\l2.exe
START /MIN waitl2run.bat
goto END
:--------------------------------------
:ERR2
COLOR 0C
echo.
echo. L2.exe not found.
echo. Place this file into your system folder.
pause
goto END
:--------------------------------------
:ERR3
COLOR 0C
echo.
echo. "%SYSDIR%\rsaenh.dll" could not be found.
pause SET /P ANSWER=Should i try to execute L2.exe (y/n)?
if /i {%ANSWER}={y}{goto YES}
if /i {%ANSWER}={Y}{goto YES}
if /i {%ANSWER}={yes}{goto YES}
if /i {%ANSWER}={YES}{goto YES}
if /i {%ANSWER}={Yes}{goto YES}
goto NO
:YES
START /MIN %L2DIR%\l2.exe
:NO
goto END
:--------------------------------------
goto END
:ERR4
COLOR 0C
echo.
echo. Could not move "%SYSDIR%\rsaenh.dll"
echo. You need to run this script as administrator.
pause
goto END
:--------------------------------------
:END