Add a script that installs ws2tcp-local from its latest release
The silent installer skips the desktop shortcut option, so the script creates the shortcut itself. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
11db14445e
commit
0356cf91f4
1 file changed
+54
@@ -0,0 +1,54 @@
|
|||||||
|
@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".
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
set "MANIFEST=https://wangguofang.net/ws2tcp-local/releases/latest.json"
|
||||||
|
set "INSTALLER=%TEMP%\ws2tcp-local-setup.exe"
|
||||||
|
|
||||||
|
echo Looking up the latest ws2tcp-local release...
|
||||||
|
set "URL="
|
||||||
|
for /f "usebackq delims=" %%U in (`powershell -NoProfile -ExecutionPolicy Bypass -Command "(Invoke-RestMethod -UseBasicParsing '%MANIFEST%').windows_url"`) do set "URL=%%U"
|
||||||
|
if not defined URL (
|
||||||
|
echo Could not read the download URL from %MANIFEST%.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Downloading %URL%...
|
||||||
|
curl.exe -fL --retry 3 -o "%INSTALLER%" "%URL%"
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo Download failed.
|
||||||
|
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%.
|
||||||
|
)
|
||||||
|
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
|
||||||
Reference in new issue
Block a user