views:

31

answers:

1

Actually I intended to ask the following question:

For an executable that lies in a directory defined in %PATH%, how can I find out in which of these directory it is found?

because I need to run Excel from C# using Process.Run(...), and just indicating "Excel" works fine: Windows seems to know where to find it. However I need to provide the appropriate working directory, too.

But in the meantime I found out that Microsoft Office is not even in the %PATH%, Windows apparently resolves it in another way.

So how could I use or mimic this functionality from Windows to get the directory containing excel?

Update: Besides the suggestion of Ruel, is there a straighter way to achieve this? I know that Windows is able to resolve the path in some way, so I'd like to reuse this functionality if possible.

Any idea?

+1  A: 

Fetch it from the registry: HKLM\SOFTWARE\Microsoft\Office\(VERSION)\Excel\InstallRoot for the VERSION it can be 10.0 11.0 etc. You can detect it by checking if there's a subkey Excel in it.

Ruel