@echo off setlocal EnableDelayedExpansion set "INSTALL_DIR=%LOCALAPPDATA%\kisync" set "EXE_NAME=kisync.exe" set "DOWNLOAD_URL=https://gitea.esh-service.ru/public/api_builder_cli_client/releases/download/v1.0.0/kisync.exe" echo. echo ========================================== echo kisync - KIS API Builder Sync - Installer echo ========================================== echo. :: Create install directory if not exist "%INSTALL_DIR%" ( mkdir "%INSTALL_DIR%" echo [+] Created directory: %INSTALL_DIR% ) else ( echo [=] Directory exists: %INSTALL_DIR% ) :: Check if exe is next to this script (offline install) if exist "%~dp0release\%EXE_NAME%" ( echo [~] Found local exe, copying... copy /Y "%~dp0release\%EXE_NAME%" "%INSTALL_DIR%\%EXE_NAME%" >nul 2>&1 goto :check_copy ) if exist "%~dp0%EXE_NAME%" ( echo [~] Found local exe, copying... copy /Y "%~dp0%EXE_NAME%" "%INSTALL_DIR%\%EXE_NAME%" >nul 2>&1 goto :check_copy ) :: Download from Gitea echo [~] Downloading kisync.exe ... echo %DOWNLOAD_URL% echo. powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%INSTALL_DIR%\%EXE_NAME%')" 2>nul :check_copy if not exist "%INSTALL_DIR%\%EXE_NAME%" ( echo. echo [!] ERROR: Failed to get kisync.exe echo Try downloading manually from: echo %DOWNLOAD_URL% echo and place it in: %INSTALL_DIR%\ echo. pause exit /b 1 ) :: Show version echo [+] Installed: %INSTALL_DIR%\%EXE_NAME% "%INSTALL_DIR%\%EXE_NAME%" --version 2>nul && echo. :: Check if already in user PATH set "NEED_PATH=1" for /f "tokens=2*" %%a in ('reg query "HKCU\Environment" /v Path 2^>nul') do set "USER_PATH=%%b" if defined USER_PATH ( echo !USER_PATH! | findstr /I /C:"%INSTALL_DIR%" >nul 2>&1 if !errorlevel!==0 ( set "NEED_PATH=0" echo [=] PATH: already configured ) ) if !NEED_PATH!==1 ( echo [~] Adding to user PATH... if defined USER_PATH ( reg add "HKCU\Environment" /v Path /t REG_EXPAND_SZ /d "%USER_PATH%;%INSTALL_DIR%" /f >nul 2>&1 ) else ( reg add "HKCU\Environment" /v Path /t REG_EXPAND_SZ /d "%INSTALL_DIR%" /f >nul 2>&1 ) :: Notify system about environment change powershell -Command "[Environment]::SetEnvironmentVariable('_kisync_refresh','1','User'); [Environment]::SetEnvironmentVariable('_kisync_refresh', $null, 'User')" 2>nul echo [+] PATH: added %INSTALL_DIR% ) echo. echo ========================================== echo Installation complete! echo ========================================== echo. echo Open a NEW terminal and run: echo kisync --help echo. echo Quick start: echo cd my-project echo kisync init echo kisync pull echo. pause