-1

第一篇文章。我有一个与批处理文件有关的有趣请求。我想知道是否可以对其进行编码,以便使用 bat 文件启动的程序将在设定的时间后终止,然后自动重新启动,然后这只是永远循环/直到程序退出。

有人有想法么?!

谢谢!!

4

1 回答 1

2

Something like this should work:

:TOP
  START /b notepad.exe
  PING 127.0.0.1 -n 5 -w 1000 > nul
  TASKKILL /im notepad.exe
GOTO :TOP

The /b for start will fire up a command in the background. We use notepad.exe in this example.

The strange ping command is a trick to get windows to sleep. -n takes a repeat count (5 in this case) and -w is the time in milisecs between pings. So this will ping 5 times with 1 sec delay between. in other words, it will wait for 5 secs.

于 2014-02-11T01:53:02.797 回答