@echo off setlocal title Install ws2tcp-local fltmc >nul 2>&1 if errorlevel 1 ( echo Please right-click this file and choose "Run as administrator". if not defined INSTALL_ALL pause exit /b 1 ) set "MANIFEST=https://wangguofang.net/ws2tcp-local/releases/latest.json" set "INSTALLER=%TEMP%\ws2tcp-local-setup.exe" set "ARCH=%PROCESSOR_ARCHITECTURE%" if defined PROCESSOR_ARCHITEW6432 set "ARCH=%PROCESSOR_ARCHITEW6432%" set "KEY=windows_x64_url" if /i "%ARCH%"=="ARM64" set "KEY=windows_arm64_url" echo Looking up the latest ws2tcp-local release (%ARCH%)... set "URL=" for /f "usebackq delims=" %%U in (`powershell -NoProfile -ExecutionPolicy Bypass -Command "(Invoke-RestMethod -UseBasicParsing '%MANIFEST%').'%KEY%'"`) do set "URL=%%U" if not defined URL ( echo Could not read the download URL from %MANIFEST%. if not defined INSTALL_ALL pause exit /b 1 ) echo Downloading %URL%... curl.exe -fL --retry 3 -o "%INSTALLER%" "%URL%" if errorlevel 1 ( echo Download failed. if not defined INSTALL_ALL pause exit /b 1 ) echo Installing ws2tcp-local... "%INSTALLER%" /S set "RC=%ERRORLEVEL%" del "%INSTALLER%" >nul 2>&1 if "%RC%"=="0" ( call :desktop_shortcut echo Done. ) else ( echo The installer exited with code %RC%. ) if not defined INSTALL_ALL pause exit /b %RC% :desktop_shortcut rem The silent installer skips its "Create desktop shortcut" option. set "EXE=%ProgramFiles%\ws2tcp-local\bin\ws2tcp-local-gui.exe" if not exist "%EXE%" ( echo Could not find %EXE%, skipping the desktop shortcut. exit /b 0 ) powershell -NoProfile -ExecutionPolicy Bypass -Command "$s=(New-Object -ComObject WScript.Shell).CreateShortcut([Environment]::GetFolderPath('CommonDesktopDirectory')+'\ws2tcp-local.lnk'); $s.TargetPath=$env:EXE; $s.WorkingDirectory=Split-Path $env:EXE; $s.Save()" exit /b 0