I start mousepad from the shell:
check, where it comes from:
start it with path:
look via ps:
ps v -C mousepad
PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND
24289 pts/3 S 0:00 3 62 85441 10964 1.0 mousepad
24292 pts/3 S 0:00 0 62 85433 10864 1.0 /usr/bin/mousepad
As we see, the one invoked without path is displayed without path, and started with the PATH, and therefore to be found by
Simple as that, isn't it?
What if I start mousepad from the menu? Well, it might be specified with or without using the PATH settings. I tried.
A normal start leads to a simple 'mousepad' in
ps v -C. Since ~/bin is the first part of my PATH I create a dummy there, and, voila, the dummy is started from the menu.
But what if you start a program which deletes itself? Which will not find the deleted program and report a wrong one, if there is a second in the path.
So that's a race condition. If you know that your programs don't delete themselves or aren't moved while you're investigating their location,
ps v -C NAME and
which NAME should work pretty well.