To clarify: The question is really: How do I locate the Mercurial command line client. If the answer is applicable to any executable, so much the better, but I'm really interested in the hg.exe
executable file.
If I know the name of an executable, say hg.exe
, the Mercurial command line client, and Windows knows where it is because I can execute just hg log
from a command prompt and it executes, what steps are involved in order for me to find that executable myself, in the same manner that the command prompt and Windows does it?
Basically, if Windows is able to locate it, I want my program to be able to locate it.
Is there a WinAPI function, or similar? The code will run in .NET, written in C#, so if there's anything built into .NET for this that would be the preferred solution, but otherwise I'm not adverse to using P/Invoke for this.
I've seen one potential duplicate of this question: c# Check if an executable exists in the windows path, but is that all there is to it? Just iterate over the contents of the PATH
environment variable and looking in each of those directories for the executable?
I have a vague notion that that's just one of the steps involved, and possibly that there are registry overrides that Windows can use that I should be aware of, so I'll post the question here.
If, on the other hand, there really is just the PATH variable in play here, it can probably safely be closed as a duplicate.