安装Interception驱动.bat 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. @echo off
  2. chcp 936 >nul
  3. setlocal EnableExtensions EnableDelayedExpansion
  4. cd /d "%~dp0"
  5. rem ---- 自动提权到管理员 ----
  6. net session >nul 2>&1
  7. if errorlevel 1 (
  8. echo 需要管理员权限安装驱动,正在请求提权...
  9. powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  10. exit /b
  11. )
  12. title Install Interception Driver
  13. echo ==================================================
  14. echo 一键安装 Interception 驱动(瞄准跟鼠标用)
  15. echo ==================================================
  16. echo.
  17. echo 装完后一般需要重启电脑才会生效。
  18. echo.
  19. set "VENDOR=%~dp0第三方"
  20. if not exist "%VENDOR%" set "VENDOR=%~dp0"
  21. set "ZIP=%VENDOR%\Interception.zip"
  22. set "WORKDIR=%TEMP%\Interception_setup_%RANDOM%"
  23. set "URL=https://github.com/oblitum/Interception/releases/download/v1.0.1/Interception.zip"
  24. rem ---- 1. 本地已有包就直接用(打包进发行版时可离线装)----
  25. if exist "%ZIP%" (
  26. echo [1/4] 使用本地安装包:
  27. echo %ZIP%
  28. goto :extract
  29. )
  30. echo [1/4] 本地没有 Interception.zip,开始下载(国内镜像自动换源)...
  31. if not exist "%VENDOR%" md "%VENDOR%"
  32. set "OK=0"
  33. call :try_dl "https://ghproxy.net/%URL%"
  34. if "!OK!"=="1" goto :extract
  35. call :try_dl "https://gh-proxy.com/%URL%"
  36. if "!OK!"=="1" goto :extract
  37. call :try_dl "https://mirror.ghproxy.com/%URL%"
  38. if "!OK!"=="1" goto :extract
  39. call :try_dl "https://ghfast.top/%URL%"
  40. if "!OK!"=="1" goto :extract
  41. call :try_dl "%URL%"
  42. if "!OK!"=="1" goto :extract
  43. echo.
  44. echo [错误] 下载失败。可手动下载后放到:
  45. echo %ZIP%
  46. echo 下载地址:
  47. echo %URL%
  48. echo 或用浏览器打开后另存为,再重新运行本脚本。
  49. pause
  50. exit /b 1
  51. :extract
  52. echo [2/4] 解压安装包...
  53. if exist "%WORKDIR%" rmdir /s /q "%WORKDIR%"
  54. md "%WORKDIR%" >nul
  55. powershell -NoProfile -Command "Expand-Archive -LiteralPath '%ZIP%' -DestinationPath '%WORKDIR%' -Force"
  56. if errorlevel 1 (
  57. echo [错误] 解压失败,zip 可能损坏。删除后重下:
  58. echo %ZIP%
  59. pause
  60. exit /b 1
  61. )
  62. set "SETUP="
  63. for /r "%WORKDIR%" %%F in (install-interception.exe) do (
  64. if exist "%%~fF" set "SETUP=%%~fF"
  65. )
  66. if not defined SETUP (
  67. echo [错误] 压缩包里找不到 install-interception.exe
  68. pause
  69. exit /b 1
  70. )
  71. echo [3/4] 正在安装驱动:
  72. echo %SETUP%
  73. "%SETUP%" /install
  74. set "RC=%errorlevel%"
  75. echo 安装程序返回码:%RC%
  76. echo [4/4] 清理临时文件...
  77. rmdir /s /q "%WORKDIR%" >nul 2>nul
  78. echo.
  79. if not "%RC%"=="0" (
  80. echo [提示] 返回码非 0,若之前已装过驱动,也可能其实已经可用。
  81. echo 可先重启再试瞄准;仍不行再看 第三方\Interception说明.txt
  82. ) else (
  83. echo 驱动安装命令已执行完成。
  84. )
  85. echo.
  86. echo ==================================================
  87. echo 请立刻重启电脑,否则瞄准跟鼠标可能无效
  88. echo ==================================================
  89. echo.
  90. choice /C YN /M "现在重启电脑吗"
  91. if errorlevel 2 goto :end
  92. if errorlevel 1 shutdown /r /t 5 /c "Interception driver installed"
  93. :end
  94. echo.
  95. echo 若选了稍后重启:重启后再开测谎提醒即可用自动瞄准。
  96. pause
  97. exit /b 0
  98. rem ---- 下载一个 URL 到 ZIP;成功设 OK=1 ----
  99. :try_dl
  100. set "U=%~1"
  101. echo 试:%U%
  102. powershell -NoProfile -Command ^
  103. "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 }"
  104. if errorlevel 1 (
  105. echo 失败,换下一个...
  106. if exist "%ZIP%" del /q "%ZIP%" >nul 2>nul
  107. exit /b 1
  108. )
  109. echo 下载成功。
  110. set "OK=1"
  111. exit /b 0