Upload error: avrdude: ser_open(): can't set com-state for "\\.\COMx"

If you are having trouble upload your Arduino board, e.g. ATMega2560, try to remove the ac-dc power adapter first. Don't know why this worked for me. But it must be stuck somewhere.