[Windows] Refactor a bit so no duplicate code.