Files
cloudhost/seediso/windows11/70-Install-ws2tcp-local-Admin.bat
T
guofangandClaude Sonnet 5.5 fccc7986d9 Pick the ws2tcp-local download URL by CPU architecture
Use windows_arm64_url on ARM64 and windows_x64_url otherwise, instead of
the generic windows_url.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 13:10:52 +08:00

60 lines
1.9 KiB
Batchfile

@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