-
Notifications
You must be signed in to change notification settings - Fork 27
/
App_V9.bat
99 lines (95 loc) · 2.74 KB
/
App_V9.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@echo off
SetLocal EnableDelayedExpansion
echo AutoLaucher v9 (2020.09.01)
set CustPython=
set CustList=(R:\Pipeline\App_Win\Python27x64\ D:\z_sys\App_Dev\Python35x64_01\ D:\z_sys\App\Python27\ D:\App\Python27\)
:: auto_launcher V9 (2020.09.01)
:: v9 (2020.09.01) re-writen detection and use method
:: v8 (2019.11.22) more auto detection and improve bat logic
:: v7 (2019.10.01) fix _x, _z auto close
:: v6 (2019.08.07): for duplicate desktop window case, it will done instead of pause; rename p3 into CustPython
:: v5 (2018.02.21): it will auto rename cmd title to cmd:AppName
:: YourPythonFileName_w.bat will launch without console
:: YourPythonFileName.bat will launch with console
:: YourPythonFileName_z.bat will launch without console in CustPython
:: YourPythonFileName_x.bat will launch with console in CustPython
:: %file:~0,-2%: is YourPythonFileName_x[:2] = YourPythonFileName
set file=%~n0
set folder=%~dp0
set useCust=0
set winMode=0
:: Detect Name
:: default
set className=%file%
:: remote python mode - no cmd window
if "%file:~-2%" equ "_z" (
set useCust=1
set winMode=1
set className=%file:~0,-2%
)
:: remote python mode - python with cmd window
if "%file:~-2%" equ "_x" (
set useCust=1
set className=%file:~0,-2%
)
:: local python mode - pythonw
if "%file:~-2%" equ "_w" (
set winMode=1
set className=%file:~0,-2%
)
:: local python mode - python
:: -- _vX case
if "%file:~-3,-1%" equ "_V" (
set className=%file:~0,-3%
)
:: -- _vXX case
if "%file:~-4,-2%" equ "_V" (
set className=%file:~0,-4%
)
REM if run ok, then go done:
REM - user close program, 0 > done
REM - program error 1 > pause
REM - program duplicate error 1 > pause
echo %className% (:cmd;_w:window;_z:cust_win;_x:cust_cmd)
if %useCust% == 0 (
REM check local python
:CHECK_PYTHON_EXIST
python --version 2>NUL
if errorlevel 1 (
set useCust=1
goto CUSTPROCESS
) else (
REM local python
if %winMode% == 1 (
start pythonw %folder%%className%.py
goto done
)
if %winMode% == 0 (
title cmd:%className%
call python %folder%%className%.py && GOTO done
goto console
)
)
)
:CUSTPROCESS
if %useCust% == 1 (
REM load cust python path
for %%x in %CustList% do (
IF EXIST %%x (
set CustPython=%%x
)
)
echo Use Python:!CustPython!
if %winMode% == 1 (
start !CustPython!pythonw.exe %folder%%className%.py
goto done
)
if %winMode% == 0 (
title cmd:%className%
call !CustPython!python.exe %folder%%className%.py && GOTO done
goto console
)
)
:console
pause
:done