@echo off
title DiskChannel One-Click Installer
echo ============================================
echo   DiskChannel - One-Click Online Installer
echo   Download ~17MB then install automatically
echo ============================================
echo.
set "WORKDIR=%USERPROFILE%\Downloads\DiskChannel_setup"
echo [1/4] Downloading package from callguard.cn ...
if not exist "%WORKDIR%" mkdir "%WORKDIR%"
cd /d "%WORKDIR%"
curl -L --fail -o dc.zip https://callguard.cn/diskchannel/DiskChannel_v6.0_setup.zip
if errorlevel 1 goto dlfail
echo [2/4] Extracting ...
if exist pkg rmdir /s /q pkg
mkdir pkg
tar -xf dc.zip -C pkg
if errorlevel 1 goto exfail
echo [3/4] Installing to %LOCALAPPDATA%\DiskChannel ...
robocopy "%WORKDIR%\pkg\DiskChannel_v6.0_setup" "%LOCALAPPDATA%\DiskChannel" /E /NFL /NDL /NJH /NJS >nul
if exist "%LOCALAPPDATA%\DiskChannel\DiskChannel.exe" goto installed
goto instfail
:installed
echo [4/4] Creating desktop shortcut ...
powershell -NoProfile -Command "$w=New-Object -ComObject WScript.Shell; $lnk=$w.CreateShortcut($w.SpecialFolders['Desktop']+'\DiskChannel.lnk'); $lnk.TargetPath=$env:LOCALAPPDATA+'\DiskChannel\DiskChannel.exe'; $lnk.WorkingDirectory=$env:LOCALAPPDATA+'\DiskChannel'; $lnk.Save()" >nul 2>&1
echo.
echo ============================================
echo   INSTALL OK! Launching DiskChannel ...
echo ============================================
start "" "%LOCALAPPDATA%\DiskChannel\DiskChannel.exe"
timeout /t 3 >nul
exit /b 0
:dlfail
echo [ERROR] Download failed. Check network and retry.
pause
exit /b 1
:exfail
echo [ERROR] Extract failed.
pause
exit /b 1
:instfail
echo [ERROR] Install failed.
pause
exit /b 1
