使用批处理脚本多次运行程序
我编写了一个程序,需要运行多次。我尝试编写一个批处理脚本来执行此操作,但它无法正常工作。
我尝试使用
@echo off
start polymer.exe
start polymer.exe
并且还尝试了
@echo off
for /l %%X in (1,1,2) do (start polymer.exe)
polymer.exe每次运行时都会将一个数字写入文件,并且很少有两个数字相同,但是当我运行这些脚本时,我在输出中得到两个相同的数字。有什么想法为什么会发生这种情况吗?
操作系统是Windows 7
I have a program I wrote that I need to run multiple times. I tried writing a batch script to do this but it's not working correctly.
I tried using
@echo off
start polymer.exe
start polymer.exe
and also tried
@echo off
for /l %%X in (1,1,2) do (start polymer.exe)
polymer.exe writes a number out to a file every time it is run and very rarely will 2 numbers be identical but when I run these scripts I get two identical numbers in the output. Any ideas why this is happening?
OS is Windows 7
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎您忘记初始化随机数生成器。
Seems like you forget to initialize your random number generator.
如果您的 exe 根据时间生成随机数,并且您无法修改它,则可以在调用之间的批处理脚本中插入暂停语句。
您可以像这样模拟等待(将暂停 3 秒):
If your exe generates a random number based on the time, and you can't modify it, you can insert a pause statement in the batch script between the calls.
You can emulate a wait like this (will pause 3 seconds):