Board logo

标题: [文本处理] [已解决]批处理中goto跳转返回后再执行出错 [打印本页]

作者: ttybs_mail    时间: 2009-7-23 12:28     标题: [已解决]批处理中goto跳转返回后再执行出错

本人系新手,昨天刚开始学批处理,自己写了一段:
  1. @echo off
  2. color 2f
  3. @echo.
  4. @echo                                   pubwin后台连接
  5. @echo.
  6. @echo             *******************************************************************
  7. @echo             *     1.文苑店    2.新金都店    4.三塘店店     5.东新园店   *
  8. @echo             *     7.中心店    8.旗舰店      9.香积东路店   10.和睦店    *
  9. @echo             *     52.华英店   53.下沙店     99.北站店      100.浙大店  *
  10. @echo.            *                                                                                                              *
  11. @echo             *                  请直接输入连锁店名前数字                      *
  12. @echo.            *                         空格退出                                   *
  13. @echo             ********************************************************************
  14. @echo off   
  15. :pubwin后台
  16. @echo.
  17. set /p input=请选择连锁店:
  18. if "%input%"=="1" goto wy
  19. if "%input%"=="2" goto xjd
  20. if "%input%"=="4" goto st        
  21. if "%input%"=="5" goto dxy
  22. if "%input%"=="7" goto zx
  23. if "%input%"=="8" goto qj
  24. if "%input%"=="10" goto hm
  25. if "%input%"=="52" goto hy
  26. if "%input%"=="53" goto xs
  27. if "%input%"=="99" goto bz
  28. if "%input%"=="100" goto zd
  29. if "%input%"==" " goto exit
  30. goto 1
  31. :1
  32. @echo on
  33. @echo             输入错误
  34. @echo                     请输入正确的店名
  35. @echo off
  36. goto pubwin后台
  37. :wy
  38. start https://192.168.1.2:8443/NetCafe
  39. goto pubwin后台
  40. :xjd
  41. start https://192.168.2.2:8443/NetCafe
  42. goto pubwin后台
  43. :st
  44. start https://192.168.4.2:8443/NetCafe
  45. goto pubwin后台
  46. :dxy
  47. start https://192.168.5.2:8443/NetCafe
  48. goto pubwin后台
  49. :zxd
  50. start https://192.168.7.2:8443/NetCafe
  51. goto pubwin后台
  52. :qj
  53. start https://192.168.8.2:8443/NetCafe
  54. goto pubwin后台
  55. :xjdl
  56. start https://192.168.9.2:8443/NetCafe
  57. goto pubwin后台
  58. :hm
  59. start https://192.168.10.2:8443/NetCafe
  60. goto pubwin后台
  61. :hy
  62. start https://192.168.52.2:8443/NetCafe
  63. goto pubwin后台
  64. :xs
  65. start https://192.168.53.3:8443/NetCafe
  66. goto pubwin后台
  67. :bz
  68. start https://192.168.99.2:8443/NetCafe
  69. goto pubwin后台
  70. :zd
  71. start https://192.168.100.2:8443/NetCafe
  72. goto pubwin后台
复制代码
第一遍运行没发现问题,但是选择后跳转回来后,不用输入,直接回车也会跳转到刚刚选择的结果,比如我输入100后,会打开https://192.168.100.2*********,同时返回到pubwin后台,但是这时回车,还是会打开https://192.168.100.2****而我要的结果是不输入就提示 输入错误
作者: more    时间: 2009-7-23 17:59

set input=&set /p input=请选择连锁店:
if not defined input echo.ERROR...
...
作者: keen    时间: 2009-7-23 19:01     标题: 回复 1楼 的帖子

请对变量input作清零处理,2楼已经给出代码。




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2