469,921 Members | 2,110 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,921 developers. It's quick & easy.

Find a Program Path

Hi,

I have created a batch file in C# and want to find and place it in the
path of an installed application. Now, this might be done on an XP,
2000, etc system. The application is installed and will likely be in
the registry. Does anyone know of anything in C# to check the
registry for a particular application path?

Say, for instance, i needed to find the Word path and place a file in
it... how to check the registry through code for this?

Thanks!
Dec 14 '07 #1
3 2806


"Soulless" wrote:
Hi,

I have created a batch file in C# and want to find and place it in the
path of an installed application. Now, this might be done on an XP,
2000, etc system. The application is installed and will likely be in
the registry. Does anyone know of anything in C# to check the
registry for a particular application path?

Say, for instance, i needed to find the Word path and place a file in
it... how to check the registry through code for this?

Thanks!
Word can be found by looking at the registry key
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0 \Word\InstallRoot" as
"Path". This is for 2007. It may not hold true for other versions.

You shouldn't count on the registry containing the info for any given
application. There is no standard for this. Also, you should not count on
the folder being writable by any given process such as copying your bat file
too it.

To get the value above, use the following:

string sKey = @"\Software\Microsoft\Office\12.0\Word\InstallRoot ";
RegistryKey key = Registry.LocalMachine.OpenSubKey(sKey);
key.GetValue("Path");

Dec 15 '07 #2
Hello Soulless,

there is no standard way to do it
just ask user to point to the installed folder

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
SHi,
S>
SI have created a batch file in C# and want to find and place it in
Sthe path of an installed application. Now, this might be done on an
SXP, 2000, etc system. The application is installed and will likely
Sbe in the registry. Does anyone know of anything in C# to check the
Sregistry for a particular application path?
S>
SSay, for instance, i needed to find the Word path and place a file in
Sit... how to check the registry through code for this?
S>
SThanks!
S>
Dec 15 '07 #3
On Dec 15, 1:02 am, Michael Nemtsev [MVP] <nemt...@msn.comwrote:
Hello Soulless,

there is no standard way to do it
just ask user to point to the installed folder

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

SHi,
S>
SI have created a batch file in C# and want to find and place it in
Sthe path of an installed application. Now, this might be done on an
SXP, 2000, etc system. The application is installed and will likely
Sbe in the registry. Does anyone know of anything in C# to check the
Sregistry for a particular application path?
S>
SSay, for instance, i needed to find the Word path and place a file in
Sit... how to check the registry through code for this?
S>
SThanks!
S>
Thanks! I am going to try to find the folder for the user and then
prompt, hopefully making life easier for all. :)
Dec 17 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Andreas Neudecker | last post: by
6 posts views Thread by Peter Hansen | last post: by
29 posts views Thread by chellappa | last post: by
5 posts views Thread by sathya moorthy via .NET 247 | last post: by
reply views Thread by citizenkahn | last post: by
reply views Thread by John Doe | last post: by
6 posts views Thread by HONOREDANCESTOR | last post: by
7 posts views Thread by latalui | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.