@echo off rem Install the pixy client on Windows from cmd.exe. rem rem curl -fsSL https://get.demotwo.site/install.cmd -o "%TEMP%\pixy-install.cmd" && "%TEMP%\pixy-install.cmd" rem rem Installs to %LOCALAPPDATA%\Programs\pixy. No administrator rights needed. rem Needs curl.exe, which ships with Windows 10 1803 and later. setlocal EnableDelayedExpansion set "BASE=https://get.demotwo.site" if not "%PIXY_BASE_URL%"=="" set "BASE=%PIXY_BASE_URL%" set "DEST=%LOCALAPPDATA%\Programs\pixy" if not "%PIXY_INSTALL%"=="" set "DEST=%PIXY_INSTALL%" set "ARCH=amd64" if /i "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "ARCH=arm64" if /i "%PROCESSOR_ARCHITEW6432%"=="ARM64" set "ARCH=arm64" set "ASSET=pixy-windows-%ARCH%.exe" where curl >nul 2>&1 if errorlevel 1 ( echo error: curl.exe not found ^(requires Windows 10 1803 or later^) exit /b 1 ) if not exist "%DEST%" mkdir "%DEST%" 2>nul if not exist "%DEST%" ( echo error: cannot create %DEST% exit /b 1 ) set "TMPF=%TEMP%\pixy-%RANDOM%%RANDOM%.exe" set "SUMF=%TEMP%\pixy-sums-%RANDOM%%RANDOM%.txt" echo. echo downloading %ASSET% curl -fsSL "%BASE%/%ASSET%" -o "%TMPF%" if errorlevel 1 ( echo error: download failed: %BASE%/%ASSET% exit /b 1 ) rem Verify against the published checksum list when it is reachable. set "GOT=" set "WANT=" curl -fsSL "%BASE%/checksums.txt" -o "%SUMF%" 2>nul if exist "%SUMF%" ( for /f "delims=" %%h in ('certutil -hashfile "%TMPF%" SHA256 ^| findstr /r /c:"^[0-9a-fA-F ]*$"') do ( if not defined GOT set "GOT=%%h" ) set "GOT=!GOT: =!" for /f "tokens=1" %%w in ('findstr /c:" %ASSET%" "%SUMF%"') do ( if not defined WANT set "WANT=%%w" ) if defined WANT ( if /i not "!GOT!"=="!WANT!" ( del /q "%TMPF%" "%SUMF%" 2>nul echo error: checksum mismatch for %ASSET% exit /b 1 ) echo checksum verified ) del /q "%SUMF%" 2>nul ) else ( echo could not fetch checksums.txt; skipping verification ) move /y "%TMPF%" "%DEST%\pixy.exe" >nul if errorlevel 1 ( del /q "%TMPF%" 2>nul echo error: could not write %DEST%\pixy.exe ^(is pixy still running?^) exit /b 1 ) echo installed %DEST%\pixy.exe rem Add to the user PATH. Read the current value from the registry rather than rem using %PATH%, which is the merged machine+user value: writing that back rem would copy every machine entry into the user PATH. set "UPATH=" for /f "tokens=2,*" %%a in ('reg query HKCU\Environment /v PATH 2^>nul ^| findstr /r /c:"REG_[A-Z_]*SZ"') do set "UPATH=%%b" set "SKIPPATH=" echo(!UPATH! | find /i "%DEST%" >nul && set "SKIPPATH=already" rem setx writes a plain string, so a user PATH containing %VAR% references would rem be frozen at today's values. Leave such a PATH alone rather than damage it. if not defined SKIPPATH ( echo(!UPATH! | find "%%" >nul && set "SKIPPATH=expandable" ) rem setx truncates at 1024 characters, which would silently destroy a long PATH. if not defined SKIPPATH ( if defined UPATH (set "NEWPATH=!UPATH!;%DEST%") else (set "NEWPATH=%DEST%") if not "!NEWPATH:~1023!"=="" set "SKIPPATH=toolong" ) if not defined SKIPPATH ( setx PATH "!NEWPATH!" >nul echo added %DEST% to your PATH set "PATHADDED=1" ) else ( if not "!SKIPPATH!"=="already" ( echo. echo NOTE: your PATH was left unchanged ^(!SKIPPATH!^). echo Add this directory yourself: echo %DEST% ) ) rem Usable immediately in this window as well. set "PATH=%PATH%;%DEST%" echo. echo pixy installed echo. echo Next: echo pixy login --token ^ echo pixy echo. if defined PATHADDED echo ^(Open a new Command Prompt for PATH changes to apply everywhere.^) if defined PATHADDED echo. endlocal exit /b 0