开发者

How to invoke a long-time task without block the existing batch script?

开发者 https://www.devze.com 2023-03-01 05:59 出处:网络
I have a long-time task implemented in Windows batch script need to be add to a existing Windows batch script, the requirement is the existing script should run just as before, without being slowed do

I have a long-time task implemented in Windows batch script need to be add to a existing Windows batch script, the requirement is the existing script should run just as before, without being slowed down by the added task.

I am thinking calling the task script in a Java thread might works, but there are some difficulties:

  1. How to call windows batch script in a Java thread?

  2. How to quit the 开发者_如何学CJava program without stop the thread?

Maybe I was wrong from the start, could any one give me some ideas?


I think adding Java code would complicate the task. You can run the additional batch file in a separate process by using the start command, and this might serve your purpose:

In first.bat:

@echo calling second.bat
start second.bat
@echo called second.bat

This will create a second command window. If you don't want that window to show up, you can use the /B parameter, as in start /B second.bat


Can't you just add something like this to your existing batch script:

start long_script.bat
0

精彩评论

暂无评论...
验证码 换一张
取 消