Change File Associations via Command Line

You can change file type associations in Windows from the command line with 2 simple commands: assoc and ftype. Use assoc to associate a file extension with a file type or check the existing association. File types are defined arbitrarily, you can make up your own if you wish:

C:\>assoc .pdf
C:\>assoc .pdf=SomeOther.PDFViewer

Then use ftype to check or set a command line to open those file types with:

C:\>ftype AcroExch.Document
AcroExch.Document="C:\Program Files (x86)\Adobe\Reader 8.0\Reader\AcroRd32.exe" "%1"
C:\>ftype SomeOther.PDFViewer=C:\Program Files\My PDF Viewer\pdfview.exe %1

These commands will edit the system-wide file associations (stored in HKLM). User-set preferences (stored in HKCU) will take precedence over this. These commands also require local admin rights, or need to be run in an elevated context (such as System during a login script, or a RunAs command).