Partially address #7385

This does not fully work on Windows, but is no worse than the current situation