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

[文本处理] 请大佬帮忙修改批处理运行后选择哪个直接跳转,谢谢。

  1. @ECHO OFF
  2. SET VERSIONS=download,uRL,cap,box
  3. SET /A DV=1
  4. SET PRESETS=1,2,3,4,5,6
  5. SET /A DP=4
  6. :BEGIN
  7. FOR %%V IN (1.2.3.4.5.6.7.8.9) DO FOR %%S IN (%CLT% %~N0 %*) DO IF /I %%~XV EQU .%%~S SET "CLT=%%~NV" & SET "VID=%%~S"
  8. IF DEFINED CLT IF NOT DEFINED VID SET "CLT="
  9. FOR %%S IN (%~N0 %*) DO IF /I %%S EQU AUTO SET /A AUTO=1
  10. IF DEFINED AUTO SET /A PRE=1 & IF NOT DEFINED CLT SET /A CLT=%DV% & IF %OS_VERSION%0 LSS 102400 SET /A CLT=13
  11. FOR %%S IN (%*) DO FOR %%P IN (1 2 3 4) DO IF %%~NS GTR 0 IF %%~NS LSS 15 IF %%~XS. EQU .%%P. SET /A PRE=%%P & SET /A CLT=%%~NS
  12. IF "%CLT%%PRE%"=="" CALL :CHOICES2 CLT "%VERSIONS%" %DV% "INVENTEC TOOLS BY CHEN.LEI" PRE "%PRESETS%" %DP% "BY CHEN.LEI" 11 WHITE 0X005A9E 320
  13. IF %CLT%0 LSS 1 IF %PRE%0 GTR 1 CALL :CHOICES CLT "%VERSIONS%" %DV% "INVENTEC TOOLS BY CHEN.LEI" 11 WHITE 0X005A9E 320
  14. IF %CLT%0 GTR 1 IF %PRE%0 LSS 1 CALL :CHOICES PRE "%PRESETS%"  %DP% "BY CHEN.LEI"  11 WHITE 0X005A9E 320
  15. IF %CLT%0 GTR 1 IF %PRE%0 LSS 1 GOTO CHOICE-0 = CANCEL
  16. GOTO CHOICE-%CLT%
  17. :CHOICE-4
  18. ECHO 4
  19. TIMEOUT /T 3
  20. GOTO :EOF
  21. :CHOICE-3
  22. ECHO 3
  23. TIMEOUT /T 3
  24. GOTO :EOF
  25. :CHOICE-2
  26. ECHO 2
  27. TIMEOUT /T 3
  28. GOTO :EOF
  29. :CHOICE-1
  30. ECHO 1
  31. TIMEOUT /T 3
  32. GOTO :EOF
  33. :CHOICE-
  34. SET /A CLT=%DV% & SET /A PRE=%DP% & GOTO CHOICE-%DV%
  35. :CHOICE-0
  36. EXIT /B
  37. ::--------------------------------------------------------------------------------------------------------------------------------
  38. #:CHOICES:#  [PARAMS] INDEXVAR "C,H,O,I,C,E,S"  [OPTIONAL]  DEFAULT-INDEX "TITLE" FONTSIZE BACKCOLOR FORECOLOR WINSIZE
  39. SET ^ #=;$F0=[IO.FILE]::READALLTEXT($ENV:0); $0=($F0-SPLIT '#\:CHOICES\:' ,3)[1]; $1=$ENV:1-REPLACE'([`@$])','`$1'; IEX($0+$1)
  40. SET ^ #=&SET "0=%~F0"& SET 1=;CHOICES %*& (FOR /F %%X IN ('POWERSHELL -NOP -C "%#%"') DO SET "%1=%%X")& EXIT /B
  41. FUNCTION CHOICES ($INDEX,$CHOICES,$DEF=1,$TITLE='CHOICES',[INT]$SZ=12,$BC='MIDNIGHTBLUE',$FC='SNOW',[STRING]$WIN='300') {
  42. [VOID][REFLECTION.ASSEMBLY]::LOADWITHPARTIALNAME('SYSTEM.WINDOWS.FORMS'); $F=NEW-OBJECT WINDOWS.FORMS.FORM; $GLOBAL:RET=''
  43. $BT=@(); $I=1; $CH=($CHOICES+',CANCEL').SPLIT(','); $CH |FOREACH {$B=NEW-OBJECT WINDOWS.FORMS.BUTTON; $B.FONT='CONSOLAS,'+$SZ
  44. $B.NAME=$I; $B.TEXT=$_;  $B.MARGIN='0,0,9,9'; $B.LOCATION='9,'+($SZ*3*$I-$SZ); $B.MINIMUMSIZE=$WIN+',18'; $B.AUTOSIZE=1
  45. $B.ADD_GOTFOCUS({$THIS.BACKCOLOR=$FC; $THIS.FORECOLOR=$BC}); $B.ADD_LOSTFOCUS({$THIS.BACKCOLOR=$BC; $THIS.FORECOLOR=$FC})
  46. $B.FLATSTYLE=0; $B.CURSOR='HAND'; $B.ADD_CLICK({$GLOBAL:RET=$THIS.NAME;$F.CLOSE()}); $F.CONTROLS.ADD($B); $BT+=$B; $I++}
  47. $F.TEXT=$TITLE; $F.BACKCOLOR=$BC; $F.FORECOLOR=$FC; $F.STARTPOSITION=4; $F.AUTOSIZE=1; $F.AUTOSIZEMODE=0; $F.MAXIMIZEBOX=0
  48. $F.ACCEPTBUTTON=$BT[$DEF-1]; $F.CANCELBUTTON=$BT[-1]; $F.ADD_SHOWN({$F.ACTIVATE();$BT[$DEF-1].FOCUS()})
  49. $F.SHOWDIALOG() >$NULL; $INDEX=$GLOBAL:RET; IF ($INDEX -EQ $CH.LENGTH) {RETURN 0} ELSE {RETURN $INDEX}
  50. } #:CHOICES:#
  51. ::--------------------------------------------------------------------------------------------------------------------------------
  52. #:CHOICES2:#  [INTERNAL]
  53. SET ^ #=;$F0=[IO.FILE]::READALLTEXT($ENV:0); $0=($F0-SPLIT '#\:CHOICES2\:' ,3)[1]; $1=$ENV:1-REPLACE'([`@$])','`$1'; IEX($0+$1)
  54. SET ^ #=&SET "0=%~F0"&SET 1=;CHOICES2 %*&(FOR /F "TOKENS=1,2" %%X IN ('POWERSHELL -NOP -C "%#%"')DO SET %1=%%X&SET %5=%%Y)&EXIT /B
  55. FUNCTION CHOICES2 {IEX($F0-SPLIT '#\:CHOICES\:' ,3)[1]; FUNCTION :LOOP { $A=$ARGS
  56. $C1 = @($A[0], $A[1], $A[2], $A[3],  $A[-4], $A[-3], $A[-2], $A[-1]); $R1= CHOICES @C1; IF ($R1 -LT 1) {RETURN "0 0"}
  57. $A_7_ = $A[1].SPLIT(',')[$R1-1] + ' ' + $A[7] #:: USE 1ST DIALOG RESULT IN THE TITLE FOR 2ND DIALOG
  58. $C2 = @($A[4], $A[5], $A[6], $A_7_,  $A[-4], $A[-3], $A[-2], $A[-1]); $R2= CHOICES @C2; IF ($R2 -GE 1) {RETURN "$R1 $R2"}
  59. IF ($R2 -LT 1) {$A[2]=$R1; :LOOP @A} }; :LOOP @ARGS #:: INDEX1 CHOICES1 DEF1 TITLE1  INDEX2 CHOICES2 DEF2 TITLE2  FONT BC TC WIN
  60. } #:CHOICES2:#
复制代码
上面是相关代码,可否改成运行后选择哪个直接跳转到:CHOICE-1,:CHOICE-2,:CHOICE-3?二级菜单可以去掉。

返回列表