我想在这样的For循环中生成一个随机数(部分):
FOR /F "delims=, eol=; tokens=1,2" %%a in (DATA.TXT) DO (
SET min=10000
SET max=99999
SET /a passwort=!min!+(!max!-!min!+1)*%random%/32768
)
不幸的是,它返回此错误:
“ * [随机生成的数字] / 32768”目前无法进行语法处理。
答案 0 :(得分:2)
!random!
,而所有
其他变量不需要%/!
进行扩展(特殊设置为/ A):: Q:\Test\2018\07\10\SO_51271717.cmd
@Echo off & SetLocal EnableExtensions EnableDelayedExpansion
SET /A "min=10000,max=99999,range=max-min+1"
FOR /F "delims=, eol=; tokens=1,2" %%a in (DATA.TXT) DO (
SET /a "passwort=min + range / 32768* !random! "
Echo passwort=!passwort!
)
示例输出:
> Q:\Test\2018\07\10\SO_51271717.cmd
passwort=10528
passwort=56868
passwort=34042
passwort=40878
passwort=32590
passwort=47396
passwort=51676
passwort=66530
passwort=40106
passwort=56218