Win auto reconnect

Port auto reconnection to Windows.
Many thanks to @vworkspace.