TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Notices

Reply
 
LinkBack Thread Tools Display Modes
Old 15-12-2007, 04:08 AM   #1
Soulless
Guest
 
Posts: n/a
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!
  Reply With Quote
Old 15-12-2007, 08:26 AM   #2
Family Tree Mike
Guest
 
Posts: n/a
RE: Find a Program Path



"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");

  Reply With Quote
Reply

Thread Tools
Display Modes


Google
 


All times are GMT +5.5. The time now is 05:05 AM.


vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional