Cherry picking a portion of
https://github.com/gmjck/winsw/commit/602d473d78e7b69fa34d6ae08328ccc5fd94658e