Commands are formated as a String.
buffer = "05100";
if (serialPort1->WriteData(buffer, sizeof(buffer)) == false)
That's not a String. It's a string. There is a world of difference in that one little (or big) letter.
. . .
I'm pretty sure that this won't compile, and IS critical for us to know to help determine your problem.
But when I do everything at the same time (first I turn on a led,a wait a second (Sleep(1000)) and I activate the servo), this did not work.
There is so much wrong with this statement. First, you can't do any two things at the same time, let alone everything.
Second, you can't turn on an LED on the PC. Even if you could, you didn't show the code for doing that.
Third, sleeping means that you aren't doing diddly for a long time. That hardly fits with the idea of doing "everything at once".
Finally, you can't attach a servo to the PC, let alone activate it.
To make it work I have to send the order twice so it works. If I send the order just once then it doesn't work. This makes no sense to me.
Perhaps you are not aware that opening the serial port resets the Arduino. It is not obvious what is happening in the ... part of your code. So, it isn't obvious what the code is doing. So, it should be obvious that we can't tell you exactly what is wrong.
g_servo8.attach(8);
You attached the servo to the smiley face on your Arduino? Which model is it? Mine doesn't have a smiley face pin.
Plus, of course everything GoForSmoke says is quite right.