View Full Version : Resolving external executables path in platform independent way

15th December 2009, 12:15

I have to implement application that can launch external applications. I thought of using QProcess for launching the external apps and it works just fine.

Now I would like to know if there is any platform independent way of finding or resolving these external application's executable paths? Let's say that I would like to find path to the MyExtApp.exe or the equivalent (MyExtApp) in unix systems. Is there anything specific in Qt that can help me with this? Or any other generic solution for my problem?

Any suggestions are welcome.


15th December 2009, 13:19
If the app is in the system path, then just run the app without an absolute directory prefix.

Otherwise you will have to search for it, depending on the application. Some applications registered with the system (eg. web and email) can be run using the URL handler.

15th December 2009, 14:57
Thanks for your reply fatjuicymole

but this doesn't quite clear the problem of how to find where the executables are located. Let's say that we cannot assume anything about the location of the executable, we just know the name of the programs executable (MyExtApp) and we have to check if there's executable with that name on the machine. If not we should get the info about that too.

So how to do the search?

I know that this might sound like an exaggeration since usually installed apps are located in certain locations (or at least their executables). But when I can check the whole machine then it's quite easy to narrow down the locations afterwards... I think ;)

And remember, this should all be done in platform independent manner... if it's even possible ;)

18th January 2010, 11:35
Hi again,

now I have tested some different methods of launching external applications and files. I have used QProcess and QDesktopServices for launching. They seem to do their job as expected in Windows but with Linux QDesktopServices doesn't want to launch external applications directly. Although it opens files, for example pdf files, as expected in default PDF reader program.

Now is there a way to get QDesktopServices to launch application executables also in Linux. Or should i just use QProcess to launch executables, as it works fine.

Here's code that does it's job as expected:

QString program = "/path/to/executable";
QStringList arguments;

QProcess *process = new QProcess(this);
process->start(program, arguments);

The following code does the job in Windows but does nothing in Linux:


So is there a way to get QDesktopServices working or should I just use QProcess to start those executables and stick with QDesktopServices with other kind of files and resources? I would really like to use just QDesktopServices to do the job because it's so simple way to launch different type of files with their default programs...

Edit: I looked the application output and it says "No application is registered as handling this file", so it seems that Linux is expecting some other application to launch these, even if the file is executable itself. Which seems quite strange... I have to take closer look at that then