Say I have a program X.EXE installed in folder c:\\abcd\\happy\\ on the system. The folder is on the system path. Now suppose there is another program
X.EXE
c:\\abcd\\happy\\
As the thread mentioned in the comment, get-command in powershell can also work it out. For example, you can type get-command npm and the output is as below:
get-command
get-command npm