You do not do Serial.begin(9600) and THEN the Arduino connects.
The Arduino is already connected (from both a software and a hardware perspective) before you even do Serial.begin(); exception might be Arduinos that can act as HID.
Also, the COM ports can change (different computer, different com port or multiple arduinos and it might depend on which one was connected first).
Question is why you would need this?
I'm using nodejs to read the com ports and need to somehow identify different arduino boards on it. All I can see that's done in nodejs is that you tell it the ports to read from and then it just gives back data from any port that sends it... it doesn't seem to know exactly what port the data is coming from, unless there's something I'm missing there.
I just want to be able to individually communicate with any given board at any given time. I was hoping I could do it via Arduino sketch but the only method I could think of is to upload a different sketch for each Arduino with a flag the Arduino can include when it sends serial data to nodejs...
But I really want to avoid having to save out a different sketch for each Arduino because it could be hundreds of Arduino boards and I just want one sketch to work for all of them.