- /*&cls&echo off&cd /d "%~dp0"
- set "length=3"
- set "count=100"
- cscript -nologo -e:jscript "%~f0" "%length%" "%count%" > "out.txt"
- pause
- exit
- */
- var len=WSH.Arguments(0).split(/[-,~]/),count=Number(WSH.Arguments(1));
- var charlist=[
- ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],
- ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],
- ["0","1","2","3","4","5","6","7","8","9"]
- ];
-
- var r1=Number(len[0]);
- function getrandom(){
- if(len.length==2){r1=Math.floor(Math.random()*(Number(len[1])-Number(len[0]))+Number(len[0]));}
- var s=[];
- for(var i=1;i<=r1;i++){
- var r2=Math.floor(Math.random()*charlist.length);
- var r3=Math.floor(Math.random()*charlist[r2].length);
- s.push(charlist[r2][r3]);
- }
- return s.join("");
- }
-
- var dic={},n=0;
- for(;;){
- var rs=getrandom();
- if(dic[rs]==undefined){
- WSH.echo(rs);
- n=n+1;dic[rs]='';
- if(n>=count){break;}
- }
- }
复制代码
|