在批处理文件中如何重复%随机%的命令? [英] How repeat %random% command in batch file?

查看:108
本文介绍了在批处理文件中如何重复%随机%的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在有限次。此批处理文件重复一个指令:

I want to repeat a command in a batch file for limited times.This command:

echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random%

不为无限!只是e.x. 40倍的使用不同的号码

我试过的的命令,但它只是给相同的数字。

I tried the For command but it just gives same numbers.

感谢

推荐答案

您需要延迟扩展。

比较这两个codesnippets的输出:

compare the output of these two codesnippets:

 for /l %%i in (1,1,10) do @echo %random%

setlocal enabledelayedexpansion
for /l %%i in (1,1,10) do @echo !random!

这篇关于在批处理文件中如何重复%随机%的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆