-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun.bat
66 lines (54 loc) · 994 Bytes
/
Run.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@echo off
REM echo 切换至 UTF8
chcp 65001 > nul
REM echo 开启延迟变量
setlocal EnableDelayedExpansion
REM test=1 输出测试内容
set test=0
if %test%==1 (
echo 当前目录
echo %~dp0
echo.
)
cd /d %~dp0
set PythonPathTxt="%~dp0PythonPath.txt"
goto FindPython
:FindPython
if %test%==1 echo 寻找 Python 程序
dir /s/b | findstr "python.exe" >> %PythonPathTxt%
for /f "usebackq delims=," %%a in (%PythonPathTxt%) do (
set "PythonPath=%%~a"
if %test%==1 echo !PythonPath!
)
del /q %PythonPathTxt%
goto FindPythonFile
:FindPythonFile
if %test%==1 (
echo.
echo 寻找 Python 脚本
)
cd /d %~dp0
for %%i in (*.py) do (
set PythonFile=%~dp0%%i
goto RunScript
)
:RunScript
title %PythonFile%
if %test%==1 (
echo %PythonFile%
echo.
echo 执行脚本
)
echo USE %PythonPath%
echo RUN %PythonFile%
echo.
if %test%==1 (
REM call "%PythonPath%"
call "%PythonPath%" "%PythonFile%"
)^
else (
call "%PythonPath%" "%PythonFile%"
)
goto exit
:End
pause & exit