-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCmdAdmin.bat
139 lines (117 loc) · 3.39 KB
/
CmdAdmin.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@echo off
:: reset
set cd=
set date=
set time=
set wlastpath=%cd%
:: get program path
set wpath=%~dp0
cd %wpath%
:: program ver
set wver=0.7
set wvdate=2023.7.23
set CA=wyf9
set wcal=False
:: CAL.bat support
if "%1" == "/cal" (
set wlastpath=%2
set wcal=True
)
::DosKey for Logging
set logging=call %wpath%sources\std\log\info
set warning=call %wpath%sources\std\log\warn
set erroring=call %wpath%sources\std\log\error
echo ================================ >>%wpath%data\running.log
::draw a text picture in Running.log :)
call sources\std\draw
%logging% Load CmdAdmin v%wver% Build date %wvdate%
%logging% Load Loading...
:: get python path config
if not exist data\config\py_path.wcfg (
%warning% Load Python Path config Lost. Change to "python".
echo python>data\config\py_path.wcfg
)
set /p wPyPath=<data\config\py_path.wcfg
%logging% Load Python Path: "%wPyPath%"
:: get start timestamp
cd.
call %wPyPath% sources\py\get_timestamp.py>nul 2>nul
if not %ERRORLEVEL% == 0 (
cd.
call sources\get_timestamp
)
set /p wLoadStart=<data\temp\time.txt
%logging% Load Load start timestamp in day: %wLoadStart%
:: reset modules num
set wvyear=2023
set wLoadModules=0
if not exist %wpath%data\config\LangNow.wcfg (
:: ¡ú¡ý if LangNow.wcfg lost
echo en-us>%wpath%data\config\LangNow.wcfg
%warning% Main Lang file lost. Changed to en-us.
echo [CA] WARNING: Langusge File lost.
echo [CA] Changed language to "en-us".
echo [CA] You can use "CASetting set LangNow *language*" to change language config.
echo And use "CA / refresh lang" to refresh language file.
)
cd.
:: get now lang
set /p wlangnow=<%wpath%data\config\LangNow.wcfg
%logging% Load Now language: %wlangnow%
%logging% Load Loading language file...
:: loading language...
for /f "eol=# delims=;" %%l in (%wpath%sources\langs\%wlangnow%.wlng) do (
set %%l>nul
)
%logging% Load %lang___load_lang_ok%
:: title
title %lang__cmd% - CmdAdmin
echo [CA] CmdAdmin v%wver% %wvdate% - %wlangnow%. %lang__all_rights_reserved%
%logging% Load %lang___init_modules%
cd.
:: load modules
for /f "eol=; delims=" %%i in ('dir %wpath%modules\ /b /s') do (
call "%%i" /winit
set /a wLoadModules=wLoadModules+1
cd.
)
%logging% Load %lang___init_modules_ok%
::doskey: CA command
doskey /OVERSTRIKE ca=%wpath%wCmd.bat $*
::change prompt to "%cd% >> "
prompt $P$S$G$G$S
:: get end timestamp
cd.
call %wPyPath% sources\py\get_timestamp.py>nul 2>nul
if not %ERRORLEVEL% == 0 (
cd.
call sources\get_timestamp
)
set /p wLoadEnd=<data\temp\time.txt
%logging% Load %lang___load_end_time%: %wLoadEnd%
:: calc load time
cd.
call %wPyPath% sources\py\wcalc.py 2 %wLoadEnd% %wLoadStart%
if not %ERRORLEVEL% == 0 (
%erroring% Load Calc Load Time Failed.
)
set /p wLoadSec=<data\temp\calced.txt
%logging% Load %lang___load_time%: %wLoadSec%s
%logging% Load %lang___load_modules_ok_1% %wLoadModules% %lang___load_modules_ok_2%.
if %wLoadModules% == 1 (
echo [CA] %lang__loaded% %wLoadModules% %lang__module%.
) else if %wLoadModules% == 0 (
echo [CA] %lang__load_modules_nope%.
) else (
echo [CA] %lang__loaded% %wLoadModules% %lang__modules%.
)
cd %wpath%wPath 2>nul
cd %wlastpath% 2>nul
%logging% Load CmdAdmin %lang___load_ok%
echo -------------------------------- >>%wpath%data\running.log
echo [CA] %lang__load_time%: %wLoadSec%s
:: CAL.bat support 2
if "%wcal%" == "True" (
cd %wpath%wPath
)
echo [CA] CmdAdmin %lang__load_ok%.