Board logo

标题: [其他] [已解决]批处理单独一行出现的%1和%2是什么含义? [打印本页]

作者: heyoug    时间: 2019-11-19 14:15     标题: [已解决]批处理单独一行出现的%1和%2是什么含义?

%1 %2单独出现在一行中,并没有其他命令和参数,这个代表什么意思?
请看第三行......
========================================================分界线========================================================
  1. @echo off
  2. setlocal EnableDelayedExpansion & cd /d "%~dp0"
  3. %1 %2
  4. ver|find "5.">nul&&goto :start
  5. mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :start","","runas",1)(window.close)&goto :eof
  6. :start
  7. set KMSSER=203.91.43.188:6188
  8. cscript //Nologo %windir%\system32\slmgr.vbs /xpr | find "已永久激活">NUL&&goto wintooff
  9. ver | find "6.1." > NUL &&  goto win7
  10. ver | find "6.2." > NUL &&  goto win8
  11. ver | find "6.3." > NUL &&  goto win81
  12. ver | find "10.0.14" > NUL &&  goto win10
  13. ver | find "10.0.17" > NUL &&  goto win2019
  14. echo 未找到合适的系统……
  15. pause
  16. exit
  17. :win7
  18. echo 当前为Windows 7/2008 R2
  19. set Professional=FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4
  20. set ProfessionalN=MRPKT-YTG23-K7D7T-X2JMM-QY7MG
  21. set ProfessionalE=W82YF-2Q76Y-63HXB-FGJG9-GF7QX
  22. set Enterprise=33PXH-7Y6KF-2VJC9-XBBR8-HVTHH
  23. set EnterpriseN=YDRBP-3D83W-TY26F-D46B2-XCKRJ
  24. set EnterpriseE=C29WB-22CC8-VJ326-GHFJW-H9DH4
  25. set ServerWeb=6TPJF-RBVHG-WBW2R-86QPH-6RTM4
  26. set ServerHPC=TT8MH-CG224-D3D7Q-498W2-9QCTX
  27. set ServerStandard=YC6KT-GKW9T-YTKYR-T4X34-R7VHC
  28. set ServerEnterprise=489J6-VHDMP-X63PK-3K798-CPX3Y
  29. set ServerDatacenter=74YFP-3QFB3-KQT8W-PMXWJ-7M648
  30. set ServerEnterpriseIA64=GT63C-RJFQ3-4GMB6-BRFB9-CB83V
  31. goto windowsstart
  32. :win8
  33. echo 当前为Windows 8/2012
  34. set ServerStandard=XC9B7-NBPP2-83J2H-RHMBY-92BT4
  35. set ServerDatacenter=48HP8-DN98B-MYWDG-T2DCC-8W83P
  36. goto windowsstart
  37. :win81
  38. echo 当前为Windows 8.1/2012 R2
  39. set ServerCloudStorageCore=3NPTF-33KPT-GGBPR-YX76B-39KDD
  40. set ServerCloudStorage=3NPTF-33KPT-GGBPR-YX76B-39KDD
  41. set ServerDatacenter=W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9
  42. set ServerDatacenterCore=W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9
  43. set ServerStandard=D2N9P-3P6X9-2R39C-7RTCD-MDVJX
  44. set ServerStandardCore=D2N9P-3P6X9-2R39C-7RTCD-MDVJX
  45. set ServerSolution=KNC87-3J2TX-XB4WP-VCPJV-M4FWM
  46. set ServerSolutionCore=KNC87-3J2TX-XB4WP-VCPJV-M4FWM
  47. goto windowsstart
  48. :win10
  49. echo 当前为Windows 10/2016
  50. set Core=TX9XD-98N7V-6WMQ6-BX7FG-H8Q99
  51. set CoreCountrySpecific=PVMJN-6DFY6-9CCP6-7BKTT-D3WVR
  52. set CoreN=3KHY7-WNT83-DGQKR-F7HPR-844BM
  53. set CoreSingleLanguage=7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH
  54. set Professional=W269N-WFGWX-YVC9B-4J6C9-T83GX
  55. set ProfessionalN=MH37W-N47XK-V7XM9-C7227-GCQG9
  56. set Enterprise=NPPR9-FWDCX-D2C8J-H872K-2YT43
  57. set EnterpriseN=DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4
  58. set Education=NW6C2-QMPVW-D7KKK-3GKT6-VCFB2
  59. set EducationN=2WH4N-8QGBV-H22JP-CT43Q-MDWWJ
  60. set EnterpriseS=WNMTR-4C88C-JK8YV-HQ7T2-76DF9
  61. set EnterpriseSN=2F77B-TNFGY-69QQF-B8YKP-D69TJ
  62. set ServerDatacenter=CB7KF-BWN84-R7R2Y-793K2-8XDDG
  63. set ServerStandard=WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY
  64. set ServerSolution=JCKRF-N37P4-C2D82-9YXRT-4M63B
  65. goto windowsstart
  66. :win2019
  67. echo 当前为Windows2019
  68. set ServerDatacenter=WMDGN-G9PQG-XVVXX-R3X43-63DFG
  69. set ServerStandard=N69G4-B89J2-4G8F4-WWYCC-J464C
  70. set ServerEssentials=WVDHN-86M7X-466 P 6-VHXV7-YY726
  71. :windowsstart
  72. for /f "tokens=3 delims= " %%i in ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "EditionID"') do set EditionID=%%i
  73. if defined %EditionID% (
  74. cscript //Nologo %windir%\system32\slmgr.vbs /ipk !%EditionID%!
  75. cscript //Nologo %windir%\system32\slmgr.vbs /skms %KMSSER%
  76. cscript //Nologo %windir%\system32\slmgr.vbs /ato
  77. )
  78. pause
  79. exit
  80. :wintooff
  81. echo 系统已经永久激活!
复制代码

作者: Batcher    时间: 2019-11-19 14:35

回复 1# heyoug


第三行下面加一行:
echo,%1 %2
观察一下执行过程试试能看明白吗?
作者: 小渣飞    时间: 2019-11-19 14:52

回复 2# Batcher


    一万多的帖子你是怎么做到的=-=
作者: heyoug    时间: 2019-11-19 15:28

回复 2# Batcher

加ECHO  就会显示空白呀,什么都没有。
作者: 小渣飞    时间: 2019-11-19 15:38

获取传值用的。

给您一个简单的示例,请把以下代码保存为“测试.bat”,放在D盘

@echo off

echo %%1的传值是 %1
echo %%2的传值是 %2
echo %%3的传值是 %3

pause
然后在cmd窗口中执行

D:\测试.bat 参数1 haha OKScript
作者: Batcher    时间: 2019-11-19 20:35

回复 4# heyoug


代码执行到第5行的时候:
shellexecute("%~s0","goto :start","","runas",1)
会调用这个bat文件自身,并传递位置参数,那个时候 %1 %2 就有值了。
作者: Batcher    时间: 2019-11-19 20:35

回复 3# 小渣飞


    在这个论坛坚持10年,你也行的
作者: heyoug    时间: 2019-11-20 08:53

回复 6# Batcher


    多谢讲解




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