[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 7# jyswjjgdwtdtj


    没太看明白你的意思,我并不是要屏蔽什么输出
一个六年级小学生,请多指教

TOP

回复 5# LTSC1809


    那个set /p 变量=<路径 那里可以看到有个0在<前面,但是我去看了源码,根本没有出现0,我也不知道为啥有个0
一个六年级小学生,请多指教

TOP

如果你只是要屏闭输出 直接>nul 不就行了
你好

TOP

回复 5# LTSC1809


    其中114.bat是我call中附带的参数,它的内容如下:
  1. @echo off
  2. mc
  3. echo a
  4. pause
复制代码
其中的mc这一行是doskey.ldt中定义的语句。它文件夹下的doskey.ldt和config.ldt内容如下,不知道这两个文件有什么用的话可以去看看这个帖子,也是我写的,去看看1楼和23楼,这两层说明了它们的作用:http://www.bathome.net/thread-66697-2-1.html
一个六年级小学生,请多指教

TOP

回复 3# Batcher

这是我通过call命令运行这个闪退的文件并且后面加上>1.txt 产生的“日志文件”,回显我开了,所以它记录了脚本退出前执行过的每一条命令,可以参考一下:
  1. C:\Users\Administrator>SetLocal EnableDelayedExpansion
  2. C:\Users\Administrator>for /F "delims=; tokens=5" %q in (C:\Users\Administrator\Desktop\bcitest\config.ldt) do if %q EQU true goto noecho
  3. C:\Users\Administrator>if true EQU true goto noecho
  4. C:\Users\Administrator>for /F "delims=; tokens=1" %o in (C:\Users\Administrator\Desktop\bcitest\config.ldt) do set conls=%o
  5. C:\Users\Administrator>set conls=100'30
  6. C:\Users\Administrator>for /F "delims=' tokens=1" %z in ("100'30") do set modc=%z
  7. C:\Users\Administrator>set modc=100
  8. C:\Users\Administrator>for /F "delims=' tokens=2" %e in ("100'30") do set modl=%e
  9. C:\Users\Administrator>set modl=30
  10. C:\Users\Administrator>for /F "delims=; tokens=2" %i in (C:\Users\Administrator\Desktop\bcitest\config.ldt) do set dbg=%i
  11. C:\Users\Administrator>set dbg=false
  12. C:\Users\Administrator>for /F "delims=; tokens=3" %t in (C:\Users\Administrator\Desktop\bcitest\config.ldt) do set dk=%t
  13. C:\Users\Administrator>set dk=true
  14. C:\Users\Administrator>for /F "delims=; tokens=4" %b in (C:\Users\Administrator\Desktop\bcitest\config.ldt) do set color=%b
  15. C:\Users\Administrator>set color=0a
  16. C:\Users\Administrator>if false EQU true (set dbgx=a )  else (if false EQU false (set dbgx=b )  else (goto configerr ) )
  17. C:\Users\Administrator>if true EQU true (set dkif=a )  else (if true EQU false (set dkif=b )  else (goto configerr ) )
  18. C:\Users\Administrator>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 0a EQU %i goto colok
  19. C:\Users\Administrator>if 0a EQU 01 goto colok
  20. C:\Users\Administrator>if 0a EQU 02 goto colok
  21. C:\Users\Administrator>if 0a EQU 03 goto colok
  22. C:\Users\Administrator>if 0a EQU 04 goto colok
  23. C:\Users\Administrator>if 0a EQU 05 goto colok
  24. C:\Users\Administrator>if 0a EQU 06 goto colok
  25. C:\Users\Administrator>if 0a EQU 07 goto colok
  26. C:\Users\Administrator>if 0a EQU 08 goto colok
  27. C:\Users\Administrator>if 0a EQU 09 goto colok
  28. C:\Users\Administrator>if 0a EQU 0a goto colok
  29. C:\Users\Administrator>rem time
  30. C:\Users\Administrator>set "t1x=17:59:56.20"
  31. C:\Users\Administrator>if "17" LSS "~,2" set "add=+24"
  32. C:\Users\Administrator>set /a "timesx=(17-~,2%addt1x:~3,2%C:\Users\Administrator\Desktop\bcitest00-1~3,2%C:\Users\Administrator\Desktop\bcitest00)*6000+(156%100-1~6,2%C:\Users\Administrator\Desktop\bcitest00)*100+(120%100-1~-2%C:\Users\Administrator\Desktop\bcitest00)" ,"ssx=(timesx/100)%60","mmx=(timesx/6000)%60","hhx=timesx/360000","msx=timesx%100"
  33. C:\Users\Administrator>rem endtime
  34. C:\Users\Administrator>if a EQU b goto nodk
  35. C:\Users\Administrator>rem time
  36. C:\Users\Administrator>set "tn=17:59:56.20"
  37. C:\Users\Administrator>rem code
  38. C:\Users\Administrator>for /F "delims=" %a in (C:\Users\Administrator\doskey.ldt) do doskey %a
  39. C:\Users\Administrator>rem time
  40. C:\Users\Administrator>set "t1n=17:59:56.20"
  41. C:\Users\Administrator>if "17" LSS "17" set "add=+24"
  42. C:\Users\Administrator>set /a "timesn=(17-17)*360000+(159%100-159%100)*6000+(156%100-156%100)*100+(120%100-120%100)" ,"ssn=(timesn/100)%60","mmn=(timesn/6000)%60","hhn=timesn/360000","msn=timesn%100"
  43. C:\Users\Administrator>rem time
  44. C:\Users\Administrator>set "t1=17:59:56.21"
  45. C:\Users\Administrator>if "17" LSS "~,2" set "add=+24"
  46. C:\Users\Administrator>set /a "times=(17-~,2%addt1:~3,2%C:\Users\Administrator\Desktop\bcitest00-1~3,2%C:\Users\Administrator\Desktop\bcitest00)*6000+(156%100-1~6,2%C:\Users\Administrator\Desktop\bcitest00)*100+(121%100-1~-2%C:\Users\Administrator\Desktop\bcitest00)" ,"ss=(times/100)%60","mm=(times/6000)%60","hh=times/360000","ms=times%100"
  47. C:\Users\Administrator>color 0a
  48. C:\Users\Administrator>mode con cols=100 lines=30
  49. C:\Users\Administrator>if b EQU a goto dbg
  50. C:\Users\Administrator>echo 加载文件:
  51. 加载文件:
  52. C:\Users\Administrator>echo 加载配置文件...
  53. 加载配置文件...
  54. C:\Users\Administrator>echo 完成 用时::.(时:分:秒.毫秒)
  55. 完成 用时::.(时:分:秒.毫秒)
  56. C:\Users\Administrator>echo 加载宏命令...
  57. 加载宏命令...
  58. C:\Users\Administrator>echo 完成 用时0:0:0.0(时:分:秒.毫秒)
  59. 完成 用时0:0:0.0(时:分:秒.毫秒)
  60. C:\Users\Administrator>echo 加载完成 总用时::.(时:分:秒.毫秒)
  61. 加载完成 总用时::.(时:分:秒.毫秒)
  62. C:\Users\Administrator>echo.
  63. C:\Users\Administrator>echo BetterCommand Interpreter development version 0.1a
  64. BetterCommand Interpreter development version 0.1a
  65. C:\Users\Administrator>echo.
  66. C:\Users\Administrator>for /F "delims=" %r in (C:\Users\Administrator\Desktop\bcitest\114.bat) do (
  67. set /p !com!= 0<C:\Users\Administrator\Desktop\bcitest\114.bat  
  68. if "!com!" EQU help C:\Users\Administrator\help.txt
  69. if "!com!" EQU exit exit
  70. if "!com!" EQU shutdown (
  71. set /p shutyn=Shutdown now?[Y/N]:  
  72. if "!shutyn!" EQU y shutdown /s /t 0 /f
  73. )  
  74. !com!
  75. )
  76. C:\Users\Administrator>(
  77. set /p !com!= 0<C:\Users\Administrator\Desktop\bcitest\114.bat  
  78. if "!com!" EQU help C:\Users\Administrator\help.txt
  79. if "!com!" EQU exit exit
  80. if "!com!" EQU shutdown (
  81. set /p shutyn=Shutdown now?[Y/N]:  
  82. if "!shutyn!" EQU y shutdown /s /t 0 /f
  83. )  
  84. !com!
  85. )
  86. C:\Users\Administrator>(
  87. set /p !com!= 0<C:\Users\Administrator\Desktop\bcitest\114.bat  
  88. if "!com!" EQU help C:\Users\Administrator\help.txt
  89. if "!com!" EQU exit exit
  90. if "!com!" EQU shutdown (
  91. set /p shutyn=Shutdown now?[Y/N]:  
  92. if "!shutyn!" EQU y shutdown /s /t 0 /f
  93. )  
  94. !com!
  95. )
  96. C:\Users\Administrator>(
  97. set /p !com!= 0<C:\Users\Administrator\Desktop\bcitest\114.bat  
  98. if "!com!" EQU help C:\Users\Administrator\help.txt
  99. if "!com!" EQU exit exit
  100. if "!com!" EQU shutdown (
  101. set /p shutyn=Shutdown now?[Y/N]:  
  102. if "!shutyn!" EQU y shutdown /s /t 0 /f
  103. )  
  104. !com!
  105. )
  106. C:\Users\Administrator>(
  107. set /p !com!= 0<C:\Users\Administrator\Desktop\bcitest\114.bat  
  108. if "!com!" EQU help C:\Users\Administrator\help.txt
  109. if "!com!" EQU exit exit
  110. if "!com!" EQU shutdown (
  111. set /p shutyn=Shutdown now?[Y/N]:  
  112. if "!shutyn!" EQU y shutdown /s /t 0 /f
  113. )  
  114. !com!
  115. )
  116. C:\Users\Administrator>exit
复制代码
一个六年级小学生,请多指教

TOP

回复 3# Batcher


    58行有个exit,所以退出了。但是去掉exit,则会直接显示配置文件存在问题。配置文件存在问题那个是59行的:configerr 那个标签。按理说会执行循环体,然后执行完循环体也就是文本的每一行都执行完了,就会碰到exit退出,但明明那个exit前面是一个for循环,循环提取文件每行内容并执行,为什么会不执行循环而是直接跑到后面的exit呢
一个六年级小学生,请多指教

TOP

回复 2# LTSC1809


每行代码下面加一行:
pause
观察一下是在第几行代码“闪退”的?
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

现在做了一个解释器,逐行获取文本里的内容并执行,使用call命令来调用它并传递两个参数,第一个参数是文件的路径(不包含文件本身名称),第二个参数是目标文件的名称,它还会读取文件路径下的config.ldt和doskey.ldt,其中config.ldt内容最后多了一个分号,后面跟着一个选项是用来决定是否显示加载中的文字和加载时间的,如果它为true,那么加载中提示和加载时间显示将会被关闭。现在它不能正常运行,会闪退,麻烦大家再帮我看看,代码如下:
  1. @echo off
  2. SetLocal EnableDelayedExpansion
  3. for /f "delims=; tokens=5" %%q in (%1\config.ldt) do if %%q equ true goto noecho
  4. rem time
  5. set "t=%time%"
  6. rem code
  7. rem time
  8. set "tx=%time%"
  9. rem code
  10. for /f "delims=; tokens=1" %%o in (%1\config.ldt) do set conls=%%o
  11. for /f "delims=' tokens=1" %%z in ("%conls%") do set modc=%%z
  12. for /f "delims=' tokens=2" %%e in ("%conls%") do set modl=%%e
  13. for /f "delims=; tokens=2" %%i in (%1\config.ldt) do set dbg=%%i
  14. for /f "delims=; tokens=3" %%t in (%1\config.ldt) do set dk=%%t
  15. for /f "delims=; tokens=4" %%b in (%1\config.ldt) do set color=%%b
  16. if %dbg% equ true (set dbgx=a) else (if %dbg% equ false (set dbgx=b) else (goto configerr))
  17. if %dk% equ true (set dkif=a) else (if %dk% equ false (set dkif=b) else (goto configerr))
  18. 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
  19. goto configerr
  20. :colok
  21. rem time
  22. set "t1x=%time%"
  23. if "%t1x:~,2%" lss "%tx:~,2%" set "add=+24"
  24. 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"
  25. rem endtime
  26. if %dkif% equ b goto nodk
  27. rem time
  28. set "tn=%time%"
  29. rem code
  30. for /f "delims=" %%a in (%cd%\doskey.ldt) do doskey %%a
  31. rem time
  32. set "t1n=%time%"
  33. if "%t1n:~,2%" lss "%tn:~,2%" set "add=+24"
  34. 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"
  35. :nodk
  36. rem time
  37. set "t1=%time%"
  38. if "%t1:~,2%" lss "%t:~,2%" set "add=+24"
  39. 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"
  40. color %color%
  41. mode con cols=%modc% lines=%modl%
  42. if %dbgx% equ a goto dbg
  43. echo 加载文件:
  44. echo 加载配置文件...
  45. echo 完成 用时%hhx%:%mmx%:%ssx%.%msx%(时:分:秒.毫秒)
  46. echo 加载宏命令...
  47. echo 完成 用时%hhn%:%mmn%:%ssn%.%msn%(时:分:秒.毫秒)
  48. echo 加载完成 总用时%hh%:%mm%:%ss%.%ms%(时:分:秒.毫秒)
  49. echo.
  50. echo BetterCommand Interpreter development version 0.1a
  51. echo.
  52. for /f "delims=" %%r in (%1\%2) do (set /p !com!=<%1\%2
  53. if "!com!" equ help %cd%\help.txt
  54. if "!com!" equ exit exit
  55. if "!com!" equ shutdown (set /p shutyn=Shutdown now?[Y/N]:
  56. if "!shutyn!" equ y shutdown /s /t 0 /f)
  57. !com!)
  58. exit
  59. :configerr
  60. echo 配置文件可能存在问题,加载失败,请检查config.ldt。
  61. pause
  62. exit
  63. :dbg
  64. @echo on
  65. for /f "delims=" %%w in (%1\%2) do (set /p com=<%1\%2
  66. if "!com!" equ help %cd%\help.txt
  67. if "!com!" equ exit exit
  68. if "!com!" equ shutdown (set /p shutyn=Shutdown now?[Y/N]:
  69. if "!shutyn!" equ y shutdown /s /t 0 /f)
  70. !com!)
  71. exit
  72. exit
  73. pause
  74. :noecho
  75. for /f "delims=; tokens=1" %%o in (%1\config.ldt) do set conls=%%o
  76. for /f "delims=' tokens=1" %%z in ("%conls%") do set modc=%%z
  77. for /f "delims=' tokens=2" %%e in ("%conls%") do set modl=%%e
  78. for /f "delims=; tokens=2" %%i in (%1\config.ldt) do set dbg=%%i
  79. for /f "delims=; tokens=3" %%t in (%1\config.ldt) do set dk=%%t
  80. for /f "delims=; tokens=4" %%b in (%1\config.ldt) do set color=%%b
  81. if %dbg% equ true (set dbgx=a) else (if %dbg% equ false (set dbgx=b) else (goto configerr))
  82. if %dk% equ true (set dkif=a) else (if %dk% equ false (set dkif=b) else (goto configerr))
  83. 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
  84. goto configerr
  85. :colokn
  86. if %dkif% equ b goto nodk
  87. for /f "delims=" %%a in (%1\doskey.ldt) do doskey %%a
  88. :nodkn
  89. for /f "delims=" %%y in (%1\%2) do (set /p com=<%1\%2
  90. if "!com!" equ help %cd%\help.txt
  91. if "!com!" equ exit exit
  92. if "!com!" equ shutdown (set /p shutyn=Shutdown now?[Y/N]:
  93. if "!shutyn!" equ y shutdown /s /t 0 /f)
  94. !com!)
  95. exit
  96. :configerrn
  97. echo 配置文件可能存在问题,加载失败,请检查config.ldt。
  98. pause
  99. exit
  100. :dbgn
  101. @echo on
  102. for /f "delims=" %%u in (%1\%2) do (set /p com=<%1\%2
  103. if "!com!" equ help %1\%2
  104. if "!com1" equ exit exit
  105. if "!com!" equ shutdown (set /p shutyn=Shutdown now?[Y/N]:
  106. if "!shutyn!" equ y shutdown /s /t 0 /f)
  107. !com!
  108. pause)
  109. exit
复制代码
一个六年级小学生,请多指教

TOP

返回列表