bat 数组
SET Obj[285]_info="Intel(R) Celeron(R) CPU N2840 @ 2.16GHz" SET Obj[286]_info="Intel(R) Celeron(R) CPU N2910 @ 1.60GHz" SET Obj[287]_info="Intel(R) Celeron(R) CPU N2920 @ 1.86GHz" SET Obj[288]_info="Intel(R) Celeron(R) CPU N2930 @ 1.83GHz" SET Obj[289]_info="Intel(R) Celeron(R) CPU N3000 @ 1.04GHz" SET Obj[290]_info="Intel(R) Celeron(R) CPU N3050 @ 1.60GHz" SET Obj[291]_info="Intel(R) Celeron(R) CPU N3060 @ 1.60GHz" SET Obj[292]_info="Intel(R) Celeron(R) CPU N3150 @ 1.60GHz" SET Obj[293]_info="Intel(R) Celeron(R) CPU N3160 @ 1.60GHz" SET Obj[294]_info="Intel(R) Celeron(R) CPU P4500 @ 1.87GHz" SET Obj[295]_info="Intel(R) Celeron(R) CPU P4505 @ 1.87GHz" SET Obj[296]_info="Intel(R) Celeron(R) CPU P4600 @ 2.00GHz" @echo off SET Obj_Index=0 SET Obj_Length=296 SET rend=0 @echo off :: 随机生成数字 SET /a rend=(%random% %%296+1) @echo off :: 读取数组 rem :LoopStart SET /A Obj_Index=%rend% IF %Obj_Index% EQU %Obj_Length% GOTO :EOF SET Obj_Current_info=0 FOR /F "usebackq delims==_ tokens=1-5" %%I IN (`SET Obj[%Obj_Index%]`) DO ( SET Obj_Current_%%J=%%K ) @echo on echo %Obj_Current_info% ::echo %rend% ECHO. rem GOTO LoopStart pause
%RANDOM% gives you a random number between 0 and 32767.
You can control the number’s range with:
set /a num=%random% %%100
– will produce number between 0~99.
This one:
set /a num=%random% %%100 +1
– will produce number between 1~100.
CMD注释形式
CMD注释形式如下:
1、:: 注释内容(第一个冒号后也可以跟任何一个非字母数字的字符)
2、rem 注释内容(不能出现重定向符号和管道符号)
3、%注释内容%(可以用作行间注释,不能出现重定向符号和管道符号)
4、:标签 注释内容(可以用作标签下方段的执行内容)