I had this problem sometime when I rewired my little studio. For some reason Windows does not like it when you plug a USB midi instrument into a different port than it was previously in. I have a couple of KORG instruments which comes with a nice utility to uninstall the MIDI drivers and therefore reuse the ports.
I understand you can use this even if you don't have any KORG gear, just download the KORG USB drivers and there is a utility called KORG MIDI Driver Uninstall Utility, just deselect the option to configure KORG gear only.