Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
Feb 1, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Executing external programs

I know that you can execute a program from a known drive using the system command, but what if you don't know the drive letter? I am trying to create a program that will be written on a CD. The Auto-run will execute this program. I want this program on the CD to have buttons to run exe's (setup files) on the CD with a single click. Therefore, since the drive changes from PC to PC, I need to know how to run off of the local drive (the one it runs off of now) like the system command. It would be helpful to know how to stop the MS-DOS window from appearing when you run the system command as well.

Assuming this is for Windows, you can use something like GetModuleFileName to obtain the complete filename of the running program including path and drive. As far as the DOS window popping up, I've only noticed this for DOS programs and not for Windows programs but, if it is an issue for you, try using ShellExecute instead of system.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date