一键安装.bat 修复:前台同步安装、先退出运行中的 Squid、每步输出与错误可见

旧版用 start 把安装器甩到后台:窗口从头到尾没有任何输出,且未先结束
正在运行的 squid-desktop——1.7MB 主程序被进程锁住时静默安装的 NSIS
会卡在替换文件一步,现象即"双击后只剩一个空命令行提示符"。新版:
1) taskkill 先退出 Squid 并留 2 秒等句柄释放;2) 复制安装包到 %TEMP%
(绕开管家对非系统盘安装器的拦截);3) 直接前台等待安装器退出并按
errorlevel 报告成败;4) 找不到安装包时给出明确错误。已端到端验证。
dev
lijunjie 2026-11-24 22:29:46 +08:00
parent 6689138c9a
commit ca84ea3b66
1 changed files with 39 additions and 2 deletions

View File

@ -1,4 +1,41 @@
@echo off
copy /Y "%~dp0Squid-Setup-0.1.13-win-x64.exe" "%TEMP%\Squid-Setup-0.1.13-win-x64.exe" >nul
start """ "%TEMP%\Squid-Setup-0.1.13-win-x64.exe" /S
rem Squid one-click installer.
rem Copies the setup to %TEMP% first: some security suites (e.g. PC Manager)
rem block unsigned installers launched from non-system drives.
setlocal
title Squid Setup
set "PKG=%~dp0Squid-Setup-0.1.13-win-x64.exe"
if not exist "%PKG%" (
echo [ERROR] Setup file not found next to this script:
echo %PKG%
echo Keep this .bat in the same folder as the setup .exe.
pause
exit /b 1
)
echo [1/3] Stopping a running Squid if any...
taskkill /F /IM squid-desktop.exe >nul 2>&1
rem The kill is asynchronous; give the OS a moment to release the exe lock.
ping -n 3 127.0.0.1 >nul
echo [2/3] Copying installer to temp folder...
copy /Y "%PKG%" "%TEMP%\Squid-Setup-0.1.13-win-x64.exe" >nul
if errorlevel 1 (
echo [ERROR] Copy to %TEMP% failed. Free up disk space or retry.
pause
exit /b 1
)
echo [3/3] Installing silently, please wait...
"%TEMP%\Squid-Setup-0.1.13-win-x64.exe" /S
if errorlevel 1 (
echo [ERROR] Installer exited with code %ERRORLEVEL%.
pause
exit /b 1
)
echo.
echo Squid 0.1.13 installed successfully.
echo (If a previous Squid was running it was closed by this script.)
pause