> but a command prompt window also opened up in the backgroud
Read the FAQ
It explains the disadvantages of system(), and gives alternative methods for starting processes on various operating systems.

system() is a barely portable catch-all way of starting a new process, but its seldom the most ideal way.