4

Suppose I am running cmd and I open an application by typing for example start document.pdf

I want to get the exact path of the executable that opens .pdf files

Of course I could search the entire system for the executable but I suppose it would be faster this way because the path is already stored somewhere

I don't know if it makes a difference but I am using Windows 7

3 Answers 3

3

Sadly the exe locations are usually defined in the registry for example. I have .txt defined as opening with "notepad++".

So to find what the association of the file is, I'd have to go to:

"Open Control Panel > Control Panel Home > Default Programs > Set Associations".

From there it'd show Notepad++ is my default program.

I'd then have to go to the registry for Notepad++ e.g.:

"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Notepad++"

And see the complete file location there something like:

C:\Program Files\Notepad++

EDIT:

Every program you install typically has a registry associated with it, where it can be configured. Most programs details can be found in:

"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node" (64 bit)
"HKEY_LOCAL_MACHINE\SOFTWARE\" (32 bit)

So you'd need to use regedit.exe to these locations, find your program and view the location of the exe

4
  • Can you develop a bit more on the "go to the registry for Notepad++" part?
    – gsmafra
    Commented Aug 27, 2015 at 8:49
  • Edited the main post
    – Jay
    Commented Aug 27, 2015 at 8:54
  • 1
    Small observation: my program was not listed in HKEY_LOCAL_MACHINE\SOFTWARE\ or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node so I ran the ctrl+f command to find it
    – gsmafra
    Commented Aug 27, 2015 at 9:23
  • 1
    It's not for certain - it's just the typical location. It can vary quite a bit.
    – Jay
    Commented Aug 27, 2015 at 9:26
15

You can get this information using two command line tools: assoc and ftype:

help assoc
Displays or modifies file extension associations

help ftype
Displays or modifies file types used in file extension associations

You can combine them to produce information you need:
for /f "delims== tokens=2" %a in ('assoc .pdf') do @ftype %a

Running this directly from command line should give you path and parameters of program registered for .pdf files

5
  • 1
    Weirdly this doesn't give me the right program. See here, my standard .pdf program is Evince and your command is returning Acrobat Reader
    – gsmafra
    Commented Aug 27, 2015 at 9:19
  • 2
    @gsmafra You're right it seems that it does not always returns expected results, as discussed eg. here: superuser.com/questions/204354/… and here: superuser.com/questions/266268/…
    – wmz
    Commented Aug 27, 2015 at 9:44
  • I can run assoc and ftype from Command Prompt, but not from Powershell. Not sure why this is.
    – AJM
    Commented Mar 30, 2020 at 13:55
  • 1
    @AJM: assoc and ftype are intrinsic commands of cmd.exe, not separate exe's. So from Powershell, you must run them through cmd: cmd /c assoc
    – Jonathan
    Commented Oct 25, 2023 at 11:35
  • @Jonathan Thanks - didn't know that.
    – AJM
    Commented Oct 25, 2023 at 14:52
0

I had the same problem, and the other solutions didn't work for me. But what did work is this:

  1. Open the program by opening a file with the approprate file extension.
  2. Go to task manager
  3. Expand the appropriate process tree (if required)
  4. Right-click on the program and click 'open file location'

This will bring you to the executable that is actually running the process.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .