HaWa
HaWa

Reputation: 229

How to run batch script for 2 hours

I have multiple batch files:

master1.bat
master2.bat
master3.bat
master4.bat

each of which when execute runs continuously in a loop until interrupted by user. How can I make a master.bat which runs master1.bat for 1st 3 hrs->Stops it and start master2.bat and so on. i.e Master.bat should do the following

Start master1.bat
 After 3 hrs Stop master1.bat
 Start master2.bat
 after 3 hrs Stop master2.bat
 start master 3.bat
 after 3 hrs Stop master3.bat

Upvotes: 1

Views: 787

Answers (1)

npocmaka
npocmaka

Reputation: 57282

with taskkill you can selectively kill a process by title.And there's a lot of ways to delay in batch file

So:

::start a bat with master1 title
start "master1" master1.bat
::wait 3 hrs
typeperf "\System\Processor Queue Length"  -sc 1 -si 18000 >nul
:: kill a window with title master1
TASKKILL /F /FI "WINDOWTITLE eq master1*"

and you can repeat this for the rest of the scripts.

Upvotes: 2

Related Questions