本帖最后由 pcl_test 于 2016-11-16 23:41 编辑
- @echo off
- rem 调用方法call :rletter 结果 长度 大小写[1小写|2大写|默认随机大小写]
- call :rletter s 5 2
- echo;%s%
- pause&exit
- :rletter
- setlocal enabledelayedexpansion
- if "%2" equ "" (set e=1) else (
- if "%2" equ "0" (set e=1) else (
- echo;%2|findstr "^[1-9][0-9]*$" >nul||set e=1
- )
- )
- if defined e echo;Error&goto :eof
- set a=abcdefghijklmnopqrstuvwxyz
- set b=ABCDEFGHIJKLMNOPQRSTUVWXYZ
- set c=AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz
- for /l %%a in (1 1 %~2) do (
- set/ai=!random!%%26,j=!random!%%52
- if "%~3" equ "1" (
- for %%i in (!i!) do set s=!s!!a:~%%i,1!
- ) else if "%~3" equ "2" (
- for %%i in (!i!) do set s=!s!!b:~%%i,1!
- ) else (
- for %%i in (!j!) do set s=!s!!c:~%%i,1!
- )
- )
- endlocal&set "%~1=%s%"&goto :eof
复制代码
|