10

it's possible? I need to get the full path of Adobe Reader including the executable name. I'm looking for on windows registries, the closer that I did was found the full path without executable name. Thanks in advance.

my code:

var adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe").OpenSubKey("Acrobat Reader");
var version = adobe.GetSubKeyNames().First();
var path = adobe.OpenSubKey(version).OpenSubKey("installer").GetValue("path");

Thanks in advance.

Jack
  • 16,276
  • 55
  • 159
  • 284

3 Answers3

22

One of these should do it for you:

    var adobe = Registry.LocalMachine
                        .OpenSubKey("Software")
                        .OpenSubKey("Microsoft")
                        .OpenSubKey("Windows")
                        .OpenSubKey("CurrentVersion")
                        .OpenSubKey("App Paths")
                        .OpenSubKey("AcroRd32.exe");

    var path = adobe.GetValue("");

    var adobeOtherWay = Registry.LocalMachine
                                .OpenSubKey("Software")
                                .OpenSubKey("Classes")
                                .OpenSubKey("acrobat")
                                .OpenSubKey("shell")
                                .OpenSubKey("open")
                                .OpenSubKey("command");

    var pathOtherWay = adobeOtherWay.GetValue("");

Pick one and run with it ;)

Didier Ghys
  • 30,396
  • 9
  • 75
  • 81
Faraday
  • 2,904
  • 3
  • 23
  • 46
  • 2
    No problem, just mark my answer as correct and I can go to sleep! :) – Faraday Jun 05 '12 at 05:51
  • Wait... Is the "AcroRd32.exe" default name of Adobe Reader independent version,architecture etc? – Jack Jun 05 '12 at 05:52
  • I'm running Windows 7 64 bit right now and it matches my old XP x86 machine. So I assume it's OK. If you have ANY trouble give me a shout and I'll write something a bit more complex to fix it. But I really don't think you'll have any issues! – Faraday Jun 05 '12 at 05:56
  • Plus, don't forget you have my second solution which doesn't require the "AcroRd32.exe" usage anyway! – Faraday Jun 05 '12 at 05:56
  • and I'm on a 32bit machine,have same name. Well.. seems default. Anything, I will back here. :) Have a good night, man. :) – Jack Jun 05 '12 at 06:00
  • That was a slow response! But cool, it's the better way IMHO. – Faraday Jun 05 '12 at 12:51
  • I said this because I have no sure if `AcroRd32.exe` is compatible with older versions, unlike 'anotherway`. If I'm wrong, tell me please. – Jack Jun 05 '12 at 13:07
  • I don't know for SURE that the AcroRd32.exe way is compatible. You made the right choice, the adobeOtherWay method was the right choice.. It's the safest option! – Faraday Jun 05 '12 at 13:11
  • On Windows Server 2003, the registry path is Software\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe – Markus Meyer Oct 19 '12 at 15:34
5

I found a problem with the "adobeOtherWay" solution. If Adobe Acrobat(not reader) is installed, then the path will point to Acrobat.exe and not the reader's exe.(I wanted to comment to above, but don't have enough reputation)

Alex
  • 127
  • 2
  • 12
3

I'm using : HKEY_CLASSES_ROOT\Software\Adobe\Acrobat\Exe It gives me the full path and exe- name of the installed Acrobat Reader, just what you need.

Johan
  • 239
  • 2
  • 8
  • This works if Acrobat Reader is the default PDF viewer. If Adobe Acrobat (ie: the paid version) is the default, it appears in this key instead. – Tridus Jan 31 '20 at 17:58