Files
2026-09-19 12:23:44 +08:00

35 lines
1.1 KiB
Batchfile
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
rem ---------------------------------------------------------------------------
rem DHT 聊天客户端启动脚本(所有参数都会透传给 python -m dhtchat)
rem 用法示例:
rem run.cmd 启动图形界面
rem run.cmd --nick 小明 指定昵称
rem run.cmd -b 192.168.1.7:47800 手动指定引导节点
rem run.cmd --no-gui 使用命令行界面
rem ---------------------------------------------------------------------------
setlocal
cd /d "%~dp0"
set "DHTCHAT_PY="
where py >nul 2>nul && py -3 -c "import sys" >nul 2>nul && set "DHTCHAT_PY=py -3"
if not defined DHTCHAT_PY (
where python >nul 2>nul && python -c "import sys" >nul 2>nul && set "DHTCHAT_PY=python"
)
if not defined DHTCHAT_PY (
echo [错误] 没有找到可用的 Python 3。
echo 请到 https://www.python.org/downloads/windows/ 安装,
echo 安装时勾选 "Add python.exe to PATH"。
exit /b 9009
)
%DHTCHAT_PY% -c "import tkinter" >nul 2>nul
if errorlevel 1 (
echo [提示] 当前 Python 缺少 tkinter,将改用命令行界面。
%DHTCHAT_PY% -m dhtchat --no-gui %*
exit /b %errorlevel%
)
%DHTCHAT_PY% -m dhtchat %*
exit /b %errorlevel%