Batch file registration code

June 7, 2011 at 22:30:51
Specs: Windows XP, 3.192 GHz / 1023 MB
i want to make a batch file that will create random 12-digit code with leters and numbers. then save it to a text file. then each time a run it again it will check to see if the code matches the one that was created. but i trued using %random% to generate the code but it could not match it. i want something like a "registration code" or a "validtation code" for my batch file.

See More: Batch file registration code

Report •

June 8, 2011 at 01:07:54
You could do it like;

if %RANDOM:~0,2%==1 set NUM1=a
if %RANDOM:~0,2%==2 set NUM1=b
if %RANDOM:~0,2%==3 set NUM1=c
if %RANDOM:~0,2%==4 set NUM1=d
if %RANDOM:~0,2%==5 set NUM1=e

if %RANDOM:~0,2%==1 set NUM2=1
if %RANDOM:~0,2%==2 set NUM2=2
if %RANDOM:~0,2%==3 set NUM2=3
if %RANDOM:~0,2%==4 set NUM2=4
if %RANDOM:~0,2%==5 set NUM2=5


echo %NUM1%-%NUM2%

%RANDOM:~0,2% displays the first 2 numbers of the variable 'RANDOM'.


Happy is ONE who says I am an OttoMAN.

Report •
Related Solutions

Ask Question