Fix hanging of diagnostics on Windows (see #10155) (rebased onto develop)



This is the same as gh-715 but rebased onto develop.

----

This PR fixes https://trac.openmicroscopy.org.uk/ome/ticket/10155. To test, deploy the server on Windows and verify that `bin\omero admin diagnostics` shows all the information and doesn't stop halfway.