BAT批处理能否实现16位随机码
在批处理文件中能不能生成16位的随机码,如果能,请给个详尽的编写,如不能,请教调用外部文件生成的16位码的方法,辛苦各位高人了!谢谢!
------解决方案--------------------给你写了个,应该是你要的效果
[code=BatchFile]
::生成十六位随机码 - Forever_Young
@echo off&setlocal enabledelayedexpansion
set "hexstr=0123456789ABCDEF"
set "ranhex="
for /l %%j in (1,1,8) do (
set /a "dec=!random!"
set "hex="
for /l %%n in (1,1,2) do (
set /a "d=dec&15,dec>>=2"
for %%d in (!d!) do set "hex=!hexstr:~%%d,1!!hex!"
)
set ranhex=!hex!!ranhex!
)
echo !ranhex!
pause
[/code]
------解决方案--------------------[code=BatchFile]@echo off & setlocal enabledelayedexpansion
set s=0123456789ABCDEF
set "result="
for /l %%a in (1,1,16) do (
set /a r=!random!%%16
call set result=!result!%%s:~!r!,1%%
)
echo %result%
pause[/code]
问题如果解决就请及时结帖,谢谢:)