Support Windows batch-mode

A better version of adding support for Windows batch-mode. On normal
setups no Stata code needs to changed. Test included.