1

I have a batch code that calls another program (meshlab) in a loop, the average time for one instance is about 6 minutes, some times it takes much more than that (possibly stuck in some complicated calculations). So I would like to know if there is a possibilty where I can set a timer for the loop to go on to the next step. Here is an example of the code:

   FOR %%I IN (C:\Users\Salam\Desktop\PreProcessed_Bosphorus\bs!var!\*.ply) DO (
        meshlabserver -i %%~dpnxI -o %%~nI.ply -s C:\Users\Salam\Desktop\PreProcessed_Bosphorus\iso_per.mlx -om vn -l %%~nI.txt
    )
4

2 回答 2

0

编辑:这个添加会杀死任何正在运行的meshlabserver.exe进程,但它总是会等待 600 秒,即使前一个任务只花了 3 分钟。

taskkill 和 timeout 在 Windows Vista 和更高版本的 IIRC 中

这将启动一个实例,并等待600几秒钟,然后它将遍历循环并启动另一个实例。您是想要kill运行进程,还是只是启动另一个 meshlabserver 实例?

FOR %%I IN (C:\Users\Salam\Desktop\PreProcessed_Bosphorus\bs!var!\*.ply) DO (
        start "" meshlabserver -i %%~dpnxI -o %%~nI.ply -s C:\Users\Salam\Desktop\PreProcessed_Bosphorus\iso_per.mlx -om vn -l %%~nI.txt
        timeout 600 >nul
        taskkill /f /im meshlabserver.exe >nul 2>&1
    )
于 2013-10-06T09:57:20.893 回答
0

不,你不能批量。FOR没有执行此操作的参数,并且您不能以其他方式中断对 meshlabserver 的调用,因为只要 meshlabserver 正在运行,批处理脚本就会被禁用。

如果您有一个支持线程的编程语言,那么您可以在后台启动 meshlabserver 程序,等待它,然后终止线程(甚至可能是进程本身),因为您喜欢它需要太长时间。

于 2013-10-06T08:45:22.897 回答