本帖最后由 LTSC1809 于 2023-7-3 20:16 编辑
回复 11# Batcher
弄好的代码如下:- @echo off
- pause
- SetLocal EnableDelayedExpansion
- pause
- for /f "delims=; tokens=5" %%q in (%1\config.ldt) do if %%q equ true goto noecho
- pause
- rem time
- pause
- set "t=%time%"
- pause
- rem code
- pause
- rem time
- pause
- set "tx=%time%"
- pause
- rem code
- pause
- for /f "delims=; tokens=1" %%o in (%1\config.ldt) do set conls=%%o
- pause
- for /f "delims=' tokens=1" %%z in ("%conls%") do set modc=%%z
- pause
- for /f "delims=' tokens=2" %%e in ("%conls%") do set modl=%%e
- pause
- for /f "delims=; tokens=2" %%i in (%1\config.ldt) do set dbg=%%i
- pause
- for /f "delims=; tokens=3" %%t in (%1\config.ldt) do set dk=%%t
- pause
- for /f "delims=; tokens=4" %%b in (%1\config.ldt) do set color=%%b
- pause
- if %dbg% equ true (set dbgx=a) else (if %dbg% equ false (set dbgx=b) else (goto configerr))
- pause
- if %dk% equ true (set dkif=a) else (if %dk% equ false (set dkif=b) else (goto configerr))
- pause
- for %%i in (01,02,03,04,05,06,07,08,09,0a,0b,0c,0d,0e,0f,10,12,16,14,15,16,17,18,19,1a,1b,1c,1d,1e,1f,20,21,23,24,25,26,27,28,29,2a,2b,2c,2d,2e,2f,30,31,32,34,35,36,37,38,39,3a,3b,3c,3d,3e,3f,40,41,42,43,45,46,47,48,49,4a,4b,4c,4d,4e,4f50,51,52,53,54,56,57,58,59,5a,5b,5c,5d,5e,5f,60,61,62,63,64,65,67,68,69,6a,6b,6c,6d,6e,6f,70,71,72,73,74,75,76,77,78,79,7a,7b,7c,7d,7e,7f,80,81,82,83,84,85,86,87,89,8a,8b,8c,8d,8e,8f,90,91,92,93,94,95,96,97,98,9a,9b,9c,9d,9e,9f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,ab,ac,ab,ac,ad,ae,af,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bc,bd,be,bf,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,cd,ce,cf,d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,da,db,dc,de,df,e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,ea,eb,ec,ed,ef,f0,f1,f2,f3,f4,f5,f6,f7,f8,f9,fa,fb,fc,fd,fe) do if %color% equ %%i goto colok
- pause
- goto configerr
- pause
- :colok
- pause
- rem time
- pause
- set "t1x=%time%"
- pause
- if "%t1x:~,2%" lss "%tx:~,2%" set "add=+24"
- pause
- set /a "timesx=(%t1x:~,2%-%tx:~,2%%add%)*360000+(1%t1x:~3,2%%%100-1%tx:~3,2%%%100)*6000+(1%t1x:~6,2%%%100-1%tx:~6,2%%%100)*100+(1%t1x:~-2%%%100-1%tx:~-2%%%100)" ,"ssx=(timesx/100)%%60","mmx=(timesx/6000)%%60","hhx=timesx/360000","msx=timesx%%100"
- pause
- rem endtime
- pause
- if %dkif% equ b goto nodk
- pause
- rem time
- pause
- set "tn=%time%"
- pause
- rem code
- pause
- for /f "delims=" %%a in (%cd%\doskey.ldt) do doskey %%a
- pause
- rem time
- pause
- set "t1n=%time%"
- pause
- if "%t1n:~,2%" lss "%tn:~,2%" set "add=+24"
- pause
- set /a "timesn=(%t1n:~,2%-%tn:~,2%%add%)*360000+(1%t1n:~3,2%%%100-1%tn:~3,2%%%100)*6000+(1%t1n:~6,2%%%100-1%tn:~6,2%%%100)*100+(1%t1n:~-2%%%100-1%tn:~-2%%%100)" ,"ssn=(timesn/100)%%60","mmn=(timesn/6000)%%60","hhn=timesn/360000","msn=timesn%%100"
- pause
- :nodk
- pause
- rem time
- pause
- set "t1=%time%"
- pause
- if "%t1:~,2%" lss "%t:~,2%" set "add=+24"
- pause
- set /a "times=(%t1:~,2%-%t:~,2%%add%)*360000+(1%t1:~3,2%%%100-1%t:~3,2%%%100)*6000+(1%t1:~6,2%%%100-1%t:~6,2%%%100)*100+(1%t1:~-2%%%100-1%t:~-2%%%100)" ,"ss=(times/100)%%60","mm=(times/6000)%%60","hh=times/360000","ms=times%%100"
- pause
- color %color%
- pause
- mode con cols=%modc% lines=%modl%
- pause
- if %dbgx% equ a goto dbg
- pause
- echo 加载文件:
- pause
- echo 加载配置文件...
- pause
- echo 完成 用时%hhx%:%mmx%:%ssx%.%msx%(时:分:秒.毫秒)
- pause
- echo 加载宏命令...
- pause
- echo 完成 用时%hhn%:%mmn%:%ssn%.%msn%(时:分:秒.毫秒)
- pause
- echo 加载完成 总用时%hh%:%mm%:%ss%.%ms%(时:分:秒.毫秒)
- pause
- echo.
- pause
- echo BetterCommand Interpreter development version 0.1a
- pause
- echo.
- pause
- for /f "delims=" %%r in (%1\%2) do (set /p !com!=<%1\%2
- pause
- if "!com!" equ help %cd%\help.txt
- pause
- if "!com!" equ exit /b exit /b
- pause
- if "!com!" equ shutdown (set /p shutyn=Shutdown now?[Y/N]:
- pause
- if "!shutyn!" equ y shutdown /s /t 0 /f)
- pause
- !com!)
- pause
- exit /b
- pause
- :configerr
- pause
- echo 配置文件可能存在问题,加载失败,请检查config.ldt。
- pause
- pause
- pause
- exit /b
- pause
- :dbg
- pause
- @echo on
- pause
- for /f "delims=" %%w in (%1\%2) do (set /p com=<%1\%2
- pause
- if "!com!" equ help %cd%\help.txt
- pause
- if "!com!" equ exit /b exit /b
- pause
- if "!com!" equ shutdown (set /p shutyn=Shutdown now?[Y/N]:
- pause
- if "!shutyn!" equ y shutdown /s /t 0 /f)
- pause
- !com!)
- pause
- exit /b
- pause
- exit /b
- pause
- pause
- pause
- :noecho
- pause
- for /f "delims=; tokens=1" %%o in (%1\config.ldt) do set conls=%%o
- pause
- for /f "delims=' tokens=1" %%z in ("%conls%") do set modc=%%z
- pause
- for /f "delims=' tokens=2" %%e in ("%conls%") do set modl=%%e
- pause
- for /f "delims=; tokens=2" %%i in (%1\config.ldt) do set dbg=%%i
- pause
- for /f "delims=; tokens=3" %%t in (%1\config.ldt) do set dk=%%t
- pause
- for /f "delims=; tokens=4" %%b in (%1\config.ldt) do set color=%%b
- pause
- if %dbg% equ true (set dbgx=a) else (if %dbg% equ false (set dbgx=b) else (goto configerr))
- pause
- if %dk% equ true (set dkif=a) else (if %dk% equ false (set dkif=b) else (goto configerr))
- pause
- for %%i in (01,02,03,04,05,06,07,08,09,0a,0b,0c,0d,0e,0f,10,12,16,14,15,16,17,18,19,1a,1b,1c,1d,1e,1f,20,21,23,24,25,26,27,28,29,2a,2b,2c,2d,2e,2f,30,31,32,34,35,36,37,38,39,3a,3b,3c,3d,3e,3f,40,41,42,43,45,46,47,48,49,4a,4b,4c,4d,4e,4f50,51,52,53,54,56,57,58,59,5a,5b,5c,5d,5e,5f,60,61,62,63,64,65,67,68,69,6a,6b,6c,6d,6e,6f,70,71,72,73,74,75,76,77,78,79,7a,7b,7c,7d,7e,7f,80,81,82,83,84,85,86,87,89,8a,8b,8c,8d,8e,8f,90,91,92,93,94,95,96,97,98,9a,9b,9c,9d,9e,9f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,ab,ac,ab,ac,ad,ae,af,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bc,bd,be,bf,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,cd,ce,cf,d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,da,db,dc,de,df,e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,ea,eb,ec,ed,ef,f0,f1,f2,f3,f4,f5,f6,f7,f8,f9,fa,fb,fc,fd,fe) do if %color% equ %%i goto colok
- pause
- goto configerr
- pause
- :colokn
- pause
- if %dkif% equ b goto nodk
- pause
- for /f "delims=" %%a in (%1\doskey.ldt) do doskey %%a
- pause
- :nodkn
- pause
- for /f "delims=" %%y in (%1\%2) do (set /p com=<%1\%2
- pause
- if "!com!" equ help %cd%\help.txt
- pause
- if "!com!" equ exit /b exit /b
- pause
- if "!com!" equ shutdown (set /p shutyn=Shutdown now?[Y/N]:
- pause
- if "!shutyn!" equ y shutdown /s /t 0 /f)
- pause
- !com!)
- pause
- exit /b
- pause
- :configerrn
- pause
- echo 配置文件可能存在问题,加载失败,请检查config.ldt。
- pause
- pause
- pause
- exit /b
- pause
- :dbgn
- pause
- @echo on
- pause
- for /f "delims=" %%u in (%1\%2) do (set /p com=<%1\%2
- pause
- if "!com!" equ help %1\%2
- pause
- if "!com1" equ exit /b exit /b
- pause
- if "!com!" equ shutdown (set /p shutyn=Shutdown now?[Y/N]:
- pause
- if "!shutyn!" equ y shutdown /s /t 0 /f)
- pause
- !com!
- pause
- pause)
- pause
- exit /b
复制代码 发现最后一次输出是:- 系统找不到文件 C:\Users\Administrator\Desktop\bcitest\C:\Users\Administrator\Desktop\bcitest\114.bat
复制代码 路径重复了两次,这是怎么回事啊 |