First set batch, then create TApplication (fixes batch Cocoa).

(cherry picked from commit 688fb2c77b68430f3ed08936019340c7c7a3954e)
Call SetBatch(), before creating the TApplication to avoid Cocoa GUI.

(cherry picked from commit 29c23634ac1d7d73858ad422f1426924b6d23aaf)
Missing header.

(cherry picked from commit 06d6c1f65ad8763775ae8cdd9e8bc411ce93d763)