I'm a beginner in batch programming. I want to create a batch script in order to create a random sequence of eight alphanumeric characters. This is my tentative:
@echo off
setlocal enabledelayedexpansion
::Initializing uppercase alphabet
set "upper=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"
set cntu=0 & for %%P in (!upper!) do (
set /a cntu+=1
set "upper[!cntu!]=%%P"
)
::Initializing lowercase alphabet
set "lower=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"
set cntl=0 & for %%P in (!lower!) do (
set /a cntl+=1
set "lower[!cntl!]=%%P"
)
::Initializing numbers
set "numbers=0 1 2 3 4 5 6 7 8 9"
set cntn=0 & for %%P in (!numbers!) do (
set /a cntn+=1
set "numbers[!cntn!]=%%P"
)
::Initializing something...
for /L %%P in (0 1 8) do (
set /a rndIntp=%random% %% 2
if %rndIntp% == 0 (
set /a rndIntu=%random% %% cntu +1
set /a psw[!%%P!]=upper[%rndIntu%]
)
if %rndIntp% == 1 (
set /a rndIntl=%random% %% cntl +1
set /a psw[!%%P!]=upper[%rndIntl%]
)
if %rndIntp% == 2 (
set /a rndIntn=%random% %% cntn +1
set /a psw[!%%P!]=upper[%rndIntn%]
)
)
pause
What's wrong? How can I outupt the created sequence? Thank you!
Aucun commentaire:
Enregistrer un commentaire