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


    运行的代码看一下

TOP

回复 11# idwma


   我在ISE中试的好像是死循环, 报下面的错
>Exception calling "SetCursorPosition" with "2" argument(s): "句柄无效。
"
At line:16 char:5
+     [Console]::SetCursorPosition(0,$mod)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ( [], MethodInvocationException
    + FullyQualifiedErrorId : IOException

Exception calling "ReadKey" with "1" argument(s): "Cannot read keys when either application does not have a console or when console input has been redirected from a file
. Try Console.Read."
At line:9 char:5
+     $i=[int][Console]::ReadKey(1).key
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidOperationException

Exception calling "SetCursorPosition" with "2" argument(s): "句柄无效。
"
At line:14 char:5
+     [Console]::SetCursorPosition(0,$mod)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException

>Exception calling "SetCursorPosition" with "2" argument(s): "句柄无效。
"
At line:16 char:5
+     [Console]::SetCursorPosition(0,$mod)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException
本人所发所有贴子或代码, 诸大侠若认为有改进之处,请不吝赐教,感激不尽!

TOP

回复 17# 5i365


    不太清楚在ise里可能不适用吧

TOP

回复 14# idwma
  1. @echo off&setlocal enabledelayedexpansion
  2. set i=0
  3. :l
  4. cls
  5. if %i%==1 set /p "=>" <nul
  6. echo [%_s1%]a
  7. if %i%==2 set /p "=>" <nul
  8. echo [%_s2%]b
  9. if %i%==3 set /p "=>" <nul
  10. echo [%_s3%]c
  11. for /f %%i in ('powershell "[int][Console]::ReadKey(1).key"') do (
  12.     if not %%i==13 (
  13.         if %%i==38 if not %i%==1 set /a i-=1
  14.         if %%i==40 if not %i%==3 set /a i+=1
  15.         if %%i==32 if defined _s!i! (set _s!i!=) else (set _s!i!=x)
  16.         goto :l
  17.     )
  18. )
  19. echo %i%
  20. for /f "delims==" %%i in ('set _s') do (
  21. set f=1
  22. if %%i==_s1 (1.bat) else if %%i==_s2 (2.bat) else if %%i==_s3 (3.bat)
  23. )
  24. if not defined f echo 空
复制代码

TOP

回复 19# ANSL


    123bat里的代码是什么样的

TOP

本帖最后由 ANSL 于 2022-4-5 18:43 编辑

回复 20# idwma
1.bat

  1. @ echo off
  2. echo running 1.bat
  3. pause
  4. exit
复制代码


2.bat
  1. @ echo off
  2. echo running 2.bat
  3. pause
  4. exit
复制代码

3.bat
  1. @ echo off
  2. echo running 3.bat
  3. pause
  4. exit
复制代码

TOP

回复 21# ANSL
  1. @echo off&setlocal enabledelayedexpansion
  2. set i=0
  3. :l
  4. cls
  5. if %i%==1 set /p "=>" <nul
  6. echo [%_s1%]a
  7. if %i%==2 set /p "=>" <nul
  8. echo [%_s2%]b
  9. if %i%==3 set /p "=>" <nul
  10. echo [%_s3%]c
  11. for /f %%i in ('powershell "[int][Console]::ReadKey(1).key"') do (
  12.     if not %%i==13 (
  13.         if %%i==38 if not %i%==1 set /a i-=1
  14.         if %%i==40 if not %i%==3 set /a i+=1
  15.         if %%i==32 if defined _s!i! (set _s!i!=) else (set _s!i!=x)
  16.         goto :l
  17.     )
  18. )
  19. echo %i%
  20. for /f "delims==" %%i in ('set _s') do (
  21. set f=1
  22. if %%i==_s1 (start 1.bat) else if %%i==_s2 (start 2.bat) else if %%i==_s3 (start 3.bat)
  23. )
  24. if not defined f echo 空
  25. pause
复制代码
1

评分人数

    • ANSL: 谢谢!技术 + 1

TOP

返回列表