Files

43 lines
961 B
Batchfile

@echo off
chcp 65001 >nul
setlocal
cd /d "%~dp0"
title 入库分拣工作站
set "PY=C:\Users\17677\AppData\Local\Programs\Python\Python312\python.exe"
if not exist "%PY%" set "PY=python"
echo [1/3] 检查运行环境...
"%PY%" -c "import tkinter, cv2, PIL, requests, serial, comtypes, pygrabber" >nul 2>&1
if errorlevel 1 (
echo 缺少依赖,正在安装 requirements.txt ...
"%PY%" -m pip install -r requirements.txt
if errorlevel 1 (
echo.
echo [错误] 依赖安装失败,请检查网络后重试。
pause
exit /b 1
)
)
echo [2/3] 检查配置...
if not exist "config.json" (
echo [错误] 找不到 config.json,请确认程序目录完整。
pause
exit /b 1
)
echo [3/3] 启动主程序...
echo.
"%PY%" main.py
set "RC=%errorlevel%"
if not "%RC%"=="0" (
echo.
echo [异常退出] 错误码 %RC%,上面的信息可以截图反馈。
pause
exit /b %RC%
)
endlocal