在后台运行计时器的批处理。怎么样? [英] Batch that runs a timer in the background. How?

查看:265
本文介绍了在后台运行计时器的批处理。怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如果这是一种使用定时器脚本(例如TIMEOUT命令)和定时器运行的批处理文件的方式,使批处理文件做其他进程。但是当定时器用完时,然后退出。 (或者执行另一个小进程)我知道这意味着te批处理文件将不得不一次运行多个进程,我只是想知道如果它可能以某种方式。

I was wondering if theres a way to make a batch file that uses a timer script (such as the TIMEOUT command) and while the timer is running, make the batch file do other processes. But when the timer runs out, then exit. (Or carry out another small process) I know this means that te batch file would have to run multiple processes at once, i just want to know if its possible somehow.

任何想法?

推荐答案

/ b cmd / c myTimeout.bat

这将在同一窗口中启动一个新应用程序(开始/?)

You can use start /b cmd /c myTimeout.bat
This starts a new application in the same window (start /?)

您应该能够同时执行多个作业

With this mechanism you should be able do multiple jobs at the same time

EDIT
对于简单的超时,这似乎有点大。
对于超时6秒,您可以使用

EDIT For a simple timeout this seems to be a bit oversized. For a timeout of 6 seconds you can use something like

set startTime=%time%
call :timeToMs startMs startTime
set /a timeoutAt=startMs + 6000
:loop
... wait for something, like a file is created, or a CD is inserted
if job_is_ready goto :leaveTheLoop
REM Test if the timeout is reached
set currentTime=%time%
call :timeToMs nowMs currentTime
if nowMs GTR timeoutAt goto :leaveTheLoop
goto :loop

:leaveTheLoop

它更适合真正的并行作业,显示作业和用于游戏的键输入作业。

It fits better for real parallel jobs, like a display job and a key-input job for a game.

这篇关于在后台运行计时器的批处理。怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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