How can I create a simple file that changes the association of PDF in Windows like the following?

run file1 → change PDF to Sumatra PDF Reader
run file2 → change PDF to FoxIt Phantom

Is there a simple solutions?

up vote 1 down vote accepted

First, get the result of this command:

assoc .pdf

It gives the current association between .pdf and its document type. In my case, the output is:

FoxitPhantomPDF.Document

Based on this output, I created two .bat files:

ftype FoxitPhantomPDF.Document="C:\Program Files\SumatraPDF\SumatraPDF.exe" "%1"

and:

ftype FoxitPhantomPDF.Document="C:\Program Files (x86)\Foxit Software\Foxit PhantomPDF\FoxitPhantomPDF.exe" "%1"

You have to run the .bat files as an admin.

Sorry, but there is a problem there:

  • when I open an administrator prompt in Windows and type the above commands they work fine (!), but when I right click on the bat files and run them as administrator they don't work!
  • Dang. Beat me to it by 10 seconds. ;-) Thanks for asking. I learned something new as a result. – Steve Rindsberg Jan 21 '17 at 22:23
  • I'm guessing that after you associate FoxitPhantomPDF.Document with SumatraPDF, PDF becomes some other type, e.g. SumatraPDF.Document, so to toggle back, you'd have to FTYPE SumatraPDF.Document= ... FoxitPhantomPDF.Exe etc. – Steve Rindsberg Jan 22 '17 at 16:36
  • that is not the case – acman123 Jan 22 '17 at 17:58
  • But I got the output ".txt=txtfile" for "assoc .txt" (Windows 10). I have UltraEdit (v. 16.2) associated with .txt files. How do you explain that? – Peter Mortensen Jul 16 at 18:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.