Find a Program Path

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Soulless

    #1

    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!
  • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

    #2
    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_MAC HINE\SOFTWARE\M icrosoft\Office \12.0\Word\Inst allRoot" 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\Mic rosoft\Office\1 2.0\Word\Instal lRoot";
    RegistryKey key = Registry.LocalM achine.OpenSubK ey(sKey);
    key.GetValue("P ath");

    Comment

    • Michael Nemtsev [MVP]

      #3
      Re: Find a Program Path

      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>


      Comment

      • Soulless

        #4
        Re: Find a Program Path

        On Dec 15, 1:02 am, Michael Nemtsev [MVP] <nemt...@msn.co mwrote:
        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. :)

        Comment

        Working...