@echo off rem ============================================================ rem Download URL (notify.exe is fetched from here on first run) -- edit as needed set "DOWNLOAD_URL=https://git.pchuan.top/cc-tools/notify/releases/download/v1.0.0/notify.exe" rem ============================================================ setlocal set "BIN=%~dp0..\bin" set "EXE=%BIN%\notify.exe" set "LOCK=%BIN%\notify.download.lock" rem first run: kick off a background download, do NOT block the hook if not exist "%EXE%" call :bootstrap if exist "%EXE%" "%EXE%" %* endlocal exit /b :bootstrap if not exist "%BIN%" mkdir "%BIN%" 2>nul rem mkdir is atomic; success = we start the download, failure = already downloading mkdir "%LOCK%" 2>nul if errorlevel 1 exit /b if exist "%EXE%" ( rmdir "%LOCK%" 2>nul & exit /b ) rem launch a detached hidden PowerShell downloader (ShellExecute breaks away from the hook) powershell -NoProfile -WindowStyle Hidden -Command "Start-Process -WindowStyle Hidden -FilePath powershell -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-File','%~dp0download.ps1','-Url','%DOWNLOAD_URL%','-Out','%EXE%','-Lock','%LOCK%')" exit /b