I haven’t used windows in a long time, but basically, it’s going to be the port that disappears when you disconnect the board, and reappears when you reconnect it. I would try the USB2 ports only.
The blink example will reduce a lot of your unknowns. Although none of the software you are trying to flash should have anything to do with the problem it’s saying you’re having.
Googling a little, this error:
“can’t set com-state for “\.\COM9””
Looks like it might be caused by something else on the machine trying to read the COM port. Do you have any other funny software that might have the COM port open? It might also be that COM9 is the wrong port, and that there’s something else (like something on the motherboard) that is using that port for its own stuff.
Lastly, don’t get too frustrated. This isn’t magic, it’s just logic, and we don’t have all the info. There’s a really simple problem here (and it could be that the arduino is just broken).
Click the folder icon on the taskbar.
Right click on This PC, click Manage.
Click Device Manager.
Click the arrow beside Ports.
What port number says Arduino Mega 2560?