The button invokes the VS compiler facility.
Think of the VS as two components. The IDE and the language compiler.
If you use VS and hit “build”, the IDE frontend starts the compiler. This compiler is a separate executable.
So it can also be run from commanline. That is what batch files are for.
Im not sure if you can separate the compiler from the IDE. They might use common code…
A different C++ compiler could theoretically work, unless the VS compiler has peculiar behavior that is exploited and the code would yield different results with a different compiler implementation.
Im not sure about C++, (still learning), but I remember from highschool C classes that some compiler behavior is undefined and the behavior is then implementation dependent…