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