devxlogo

Executing external programs

Executing external programs

Question:
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.

Answer:
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.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist