My setup:
My parent batch file executes seven child bat files then sends out an email telling me they've completed :
START "MyProcess1" C:/2oh/100a.bat
PING 127.0.0.1 -n 5 || PING ::1 -n 5
START "MyProcess2" C:/2oh/100b.bat
PING 127.0.0.1 -n 5 || PING ::1 -n 5
START "MyProcess3" C:/2oh/101a.bat
PING 127.0.0.1 -n 5 || PING ::1 -n 5
START "MyProcess4" C:/2oh/101b.bat
PING 127.0.0.1 -n 5 || PING ::1 -n 5
START "MyProcess5" C:/2oh/102.bat
PING 127.0.0.1 -n 5 || PING ::1 -n 5
START "MyProcess6" C:/2oh/103.bat
PING 127.0.0.1 -n 5 || PING ::1 -n 5
START "MyProcess7" C:/2oh/104.bat
:loop
timeout /t 1 >nul
tasklist /v|find "MyProcess">nul && goto :loop
echo all tasks have finished..
sendEmail -f analyticsqa@gmail.com
The child bat file is a simple call to execute a ruby script like so.
C:/2oh/104.rb
exit
The ruby script is like so:
require_relative "./helper"
require_relative "./tests"
require 'logger'
class Tests < Test::Unit::TestCase
self.test_order = :defined
$stdout.reopen("log.txt", "a")
def test_average_first_run
puts "First Run"
test_first_run
end
So essentially - these seven ruby scripts are writing their contents to a single log file, then the parent batch file is emailing out that log. For whatever reason it seems to always get stuck on one of the batch files. It's done, there's nothing else to execute but the bat file doesn't close, as you can see in this screenshot, it just writes the exit to the screen but doesn't execute the command. So that won't close, which means the parent batch file doesn't close, so no emailed log. There's absolutely no difference in batch files or ruby scripts, they are all identical children. So for the life of me I cannot figure out why the batch file won't exit. If I execute this bat file independently it works just fine.