Is there any command through which I can find that user has selected a particular program (eg Adobe reader/Adobe acrobat) as default program for a particular file extension (eg .pdf) in Windows?
More specifically:
adobe reader
as default PDF viewer
from file properties viewer1 = "Command .pdf"
(running in command prompt) viewer2 = "Command .pdf"
(running in command prompt) So, viewer1 != viewer2
I am working in Java swing, so if there is any library or way to find default program selected to .pdf file, that would also helpful for me.
Does any registry key exist, that stores default program path for specific file extension (.pdf)?
EDITED
Okay so I missed a part here. It consists of two commands.
assoc
to get the filetype association with the extension eg .jpg=jpegimage
ftype
to get the default handler ftype jpegimage
Hope that helps. I suppose you could pipeline the two but I have no idea how thats done in Windows.
The default command associated with a given extension can be determined like this:
for /F "tokens=2 delims==" %a in ('assoc .pdf') do ftype %a
Change %a
to %%a
if you want to use this in a batch file.
A manual override of the associated command via the file's properties, however, seems to be stored elsewhere (in the Progid
value of the key HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.pdf\\UserChoice
to be specific), so it won't be detected by assoc
. You can read it from the registry like this:
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf\UserChoice /v Progid
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.