Windows build fix attempt

This is based on mailing list comments, untested. Please merge after review, likely to be better than the current state.

DIRUNLINK is an open question, it currently calls unlink.sh