So please describe your system a little bit more detailed than with the error message:
the error: avrdude: ser_open(): can't open device "\\.\COM12": access denied
The "access denied" message directs to a problem with the Windows user account control (uac) restrictions.
So what might be the problem, that your access to COM12 is denied by the system?
Software installed as an "Administrator" and trying to use as a "Standard User"?
Is it a "normal" installation of something like "Windows 7 Home Premium Edition"?
Or is it some kind of "virtualized" operating system that prevents you from using all ressources of the system due to configuration settings of the hosting system?
i tried with administrator and with a standard user, my windows is windows 7 home premium, i don't know why is is denied, with my other arduino it works
Ghislacchio:
i tried with administrator and with a standard user, my windows is windows 7 home premium, i don't know why is is denied, with my other arduino it works
And you are sure that COM12 is really the COM port of your MEGA?
When you open the Device Manager and connect the board to USB, COM12 appears? And if you disconnect the board COM12 disappears?
Would it be possible that you use some software with "Serial auto detect" features, such as possibly mobile phone software? If you are running any software with features like "Serial port auto detect" you should deactivate the "auto detect" feature and set to "manual COM port setting".
not sure if this will help as I am new, but, I have several Megas, and I was not able to upload, even though everything said it was set properly, I replaced the USB cable and never had the problem again
If you have several Megas, you probably know what you are doing, and I think the real problem is that you have several Megas and this confuses Arduino or Windows, probably both, and may even be confusing you.
I have had similar problems although I don't think I was actually told access was denied. I despaired for a while and ran one on another computer but I think it has now sorted itself out. I believe I did this by re-installing the IDE from scratch. I don't suppose that I need remind you the every Mega works off a different COM port and those ports will be different on other computers. Put labels on the Megas and make a table in NotePad.
I get that ser_drain() too sometimes. Im using 1.5.7 and it happens to all of my boards. However if I use 1.0.6 it works with no problem. I think it might be a bug with the IDE.
It could be the dreaded fake ftdi chip issue. There's a zip file available with drivers that work with the fake chips. I can't remember where I downloaded them from but I still have the zip file sitting on my machine here.