I have some batch files which need to be run asynchronously in following order on 6 remote servers located on same network and all servers having common username & password to login. I have put Master.bat file on Server5.
STEP1 :Run file1.bat on 4 different servers (Server1, Server2, Server3, Server4) in parallel
STEP2 :Run file2.bat on 2 different servers (Server5, Server6) in parallel
STEP3 :Run file3.bat on Server5 (which is local server in my case as Master.bat is on Server5 only )
STEP4 :Run file4.bat on 2 same servers as in STEP2 (Server5, Server6) in parallel
STEP5 :Run file5.bat on 4 same servers as in STEP1 (Server1, Server2, Server3, Server4) in parallel
I have planned to do this as follows :
Serverlist1.txt :
Server1 ip
Server2 ip
Server3 ip
Server4 ip
Serverlist2.txt :
Server5 ip
Server6 ip
Master.bat :
@echo off
setlocal enabledelayedexpansion
for /F "delims= " %i in (C: estServerlist1.txt) do ( psexec \%i C: estfile1.bat )
for /F "delims= " %i in (C: estServerlist2.txt) do ( psexec \%i C: estfile2.bat )
call file3.bat
for /F "delims= " %i in (C: estServerlist2.txt) do ( psexec \%i C: estfile4.bat )
for /F "delims= " %i in (C: estServerlist1.txt) do ( psexec \%i C: estfile5.bat )
I havn't tested it yet so not sure whether multiple FOR loops in a Master.bat file will be waiting for each other to be finished or not ?. Should I put these FOR loops in other Batch files and them CALL them in Master.bat ?
This all seems bit lengthy to me.Is there any simple method to do this ?
Need help !
EDIT1
file1.bat
taskkill /f /im firefox.exe
net stop W3SVC
sc config W3SVC start= demand
net start W3SVC
I want file1.bat to wait until the "SUCCESS" signal is received.Where I should put waitfor SUCCESS
command in file1.bat file ?
In above Master.bat file where I should insert waitfor /SI SUCCESS
command to send a signal to file1.bat to start running ?
Actually I have to define different Signal Name for all the five batch files, sothat I can run them one after another as per 5 steps mentioned above.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…