mercredi 9 septembre 2020

Want to create a program in batch that generates a string then adds on to that string

i want a string of 6 random alphanumeric characters to be created to be created then on the back of that string 27 alphanumeric characters be added. heres what i have so far

EDIT: semi fixed code for some reason the end of last string has random length instead of 27

    @Echo Off
color 0a
:start
cls
Setlocal EnableDelayedExpansion
Set _RNDLength=6
Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678-9
Set _Str=%_Alphanumeric%987654321
:_LenLoop
IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
SET _tmp=%_Str:~9,1%
SET /A _Len=_Len+_tmp
Set _count=0
SET _RndAlphaNum=
:_loop
Set /a _count+=1
SET _RND=%Random%
Set /A _RND=_RND%%%_Len%
SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
If !_count! lss %_RNDLength% goto _loop
set guen= NTAzNjA4OTcxOTEyMDE5OTY5. !_RndAlphaNum! .
Set _RNDLength= 27
 

cls Setlocal EnableDelayedExpansion Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678-9 Set _Str=%_Alphanumeric%987654321 :1_LenLoop IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :1_LenLoop SET _tmp=%_Str:~9,1% SET /A _Len=_Len+_tmp Set _count=0 SET _RndAlphaNum= :1_loop Set /a _count+=1 SET _RND=%Random% Set /A _RND=_RND%%%_Len% SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1! If !_count! lss %_RNDLength% goto 1_loop set guen2= %guen% !_RndAlphaNum! echo %guen2% pause




Aucun commentaire:

Enregistrer un commentaire