| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- @echo off
- chcp 936 >nul
- setlocal EnableExtensions EnableDelayedExpansion
- cd /d "%~dp0"
- rem ---- 自动提权到管理员 ----
- net session >nul 2>&1
- if errorlevel 1 (
- echo 需要管理员权限安装驱动,正在请求提权...
- powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
- exit /b
- )
- title Install Interception Driver
- echo ==================================================
- echo 一键安装 Interception 驱动(瞄准跟鼠标用)
- echo ==================================================
- echo.
- echo 装完后一般需要重启电脑才会生效。
- echo.
- set "VENDOR=%~dp0第三方"
- if not exist "%VENDOR%" set "VENDOR=%~dp0"
- set "ZIP=%VENDOR%\Interception.zip"
- set "WORKDIR=%TEMP%\Interception_setup_%RANDOM%"
- set "URL=https://github.com/oblitum/Interception/releases/download/v1.0.1/Interception.zip"
- rem ---- 1. 本地已有包就直接用(打包进发行版时可离线装)----
- if exist "%ZIP%" (
- echo [1/4] 使用本地安装包:
- echo %ZIP%
- goto :extract
- )
- echo [1/4] 本地没有 Interception.zip,开始下载(国内镜像自动换源)...
- if not exist "%VENDOR%" md "%VENDOR%"
- set "OK=0"
- call :try_dl "https://ghproxy.net/%URL%"
- if "!OK!"=="1" goto :extract
- call :try_dl "https://gh-proxy.com/%URL%"
- if "!OK!"=="1" goto :extract
- call :try_dl "https://mirror.ghproxy.com/%URL%"
- if "!OK!"=="1" goto :extract
- call :try_dl "https://ghfast.top/%URL%"
- if "!OK!"=="1" goto :extract
- call :try_dl "%URL%"
- if "!OK!"=="1" goto :extract
- echo.
- echo [错误] 下载失败。可手动下载后放到:
- echo %ZIP%
- echo 下载地址:
- echo %URL%
- echo 或用浏览器打开后另存为,再重新运行本脚本。
- pause
- exit /b 1
- :extract
- echo [2/4] 解压安装包...
- if exist "%WORKDIR%" rmdir /s /q "%WORKDIR%"
- md "%WORKDIR%" >nul
- powershell -NoProfile -Command "Expand-Archive -LiteralPath '%ZIP%' -DestinationPath '%WORKDIR%' -Force"
- if errorlevel 1 (
- echo [错误] 解压失败,zip 可能损坏。删除后重下:
- echo %ZIP%
- pause
- exit /b 1
- )
- set "SETUP="
- for /r "%WORKDIR%" %%F in (install-interception.exe) do (
- if exist "%%~fF" set "SETUP=%%~fF"
- )
- if not defined SETUP (
- echo [错误] 压缩包里找不到 install-interception.exe
- pause
- exit /b 1
- )
- echo [3/4] 正在安装驱动:
- echo %SETUP%
- "%SETUP%" /install
- set "RC=%errorlevel%"
- echo 安装程序返回码:%RC%
- echo [4/4] 清理临时文件...
- rmdir /s /q "%WORKDIR%" >nul 2>nul
- echo.
- if not "%RC%"=="0" (
- echo [提示] 返回码非 0,若之前已装过驱动,也可能其实已经可用。
- echo 可先重启再试瞄准;仍不行再看 第三方\Interception说明.txt
- ) else (
- echo 驱动安装命令已执行完成。
- )
- echo.
- echo ==================================================
- echo 请立刻重启电脑,否则瞄准跟鼠标可能无效
- echo ==================================================
- echo.
- choice /C YN /M "现在重启电脑吗"
- if errorlevel 2 goto :end
- if errorlevel 1 shutdown /r /t 5 /c "Interception driver installed"
- :end
- echo.
- echo 若选了稍后重启:重启后再开测谎提醒即可用自动瞄准。
- pause
- exit /b 0
- rem ---- 下载一个 URL 到 ZIP;成功设 OK=1 ----
- :try_dl
- set "U=%~1"
- echo 试:%U%
- powershell -NoProfile -Command ^
- "try { $ProgressPreference='SilentlyContinue'; Invoke-WebRequest -Uri '%U%' -OutFile '%ZIP%' -UseBasicParsing -TimeoutSec 90; if ((Get-Item '%ZIP%').Length -lt 50000) { exit 2 } else { exit 0 } } catch { exit 1 }"
- if errorlevel 1 (
- echo 失败,换下一个...
- if exist "%ZIP%" del /q "%ZIP%" >nul 2>nul
- exit /b 1
- )
- echo 下载成功。
- set "OK=1"
- exit /b 0
|