Search code examples
filecmdassociations

File association using CMD


What are ways to associate file from cmd? For example,I want .txt file extension to associate with a typical program, through command prompt? what is the correct file association cmd command?


Solution

  • One needs to use ftype and assoc commands as follows (and note that sequence matters):

    ftype txtfile="C:\Program Files (x86)\PSPad editor\PSPad.exe" "%1"
    assoc .log=txtfile
    assoc .txt=txtfile
    assoc .wtx=txtfile
    

    or

    ftype TIFImage.Document="C:\Program Files\MSPVIEW.exe" "%1"
    assoc .tif=TIFImage.Document
    assoc .tiff=TIFImage.Document
    

    Note that I haven't MSPVIEW.exe installed so I can't approve your ftype assignment rightness. In my Windows ftype TIFImage.Document command output is as follows:

    TIFImage.Document=%SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %1