Associate a File Type with a Specific Program

42,234

Solution 1

Method #1 (on the fly):

  1. Right-click a file of the type you want to change, and select Properties.
  2. In the General tab, click the Change button.
  3. Choose a program from the list, or click Browse to select an .EXE file on your hard disk.

Method #2 (view a list of file types):

  1. Open Control Panel.
  2. In Control Panel Home, click Programs, and then click Make a file type always open in a specific program.

    Or, in the Classic View, open Default Programs and then click Associate a file type or protocol with a program.

  3. Highlight a file type in the list and click Change Program.

Unfortunately, neither method in Vista allows you to choose anything but the default programs, such as the programs listed in your files' context menus. If you want complete control over your file types, use this tool:

Method #3 (File Type Doctor):

  1. Download and install Creative Element Power Tools.
  2. Open the Creative Element Power Tools Control Panel.
  3. Turn on the Edit file type associations option, and click Accept.
  4. Right-click a file of the type you want to change, and select Edit File Type to show this window:

alt text

Source

Solution 2

How about Method #5 (for people who like the command line):

  1. Open an elevated command prompt.
  2. Use FTYPE {fileType}={commandString} to create a file type and associated command to open the file.
  3. Use ASSOC {.fileExtension}={fileType} to associate a file extension with the file type you created.

Example:

FTYPE MyCustomType=C:\Program Files\MyCustomProgram\MyProg.exe "%1"
ASSOC .custom=MyCustomType

Note that many file types may already be registered on your system. You can list them all by just typing FTYPE with no arguments.

Solution 3

The following example .bat file show how to associate a file type with a specific program and icon will not be ugly:

enter image description here

set ftypename=potato_xxx_file
set extension=.potato
set pathtoexe="C:\potato.exe"
set pathtoicon=""

if %pathtoicon%=="" set pathtoicon=%pathtoexe%,0
REG ADD HKEY_CLASSES_ROOT\%extension%\ /t REG_SZ /d %ftypename% /f
REG ADD HKLM\SOFTWARE\Classes\%ftypename%\DefaultIcon\ /t REG_SZ /d %pathtoicon% /f
ftype %ftypename%=%pathtoexe% "%%1" %%*
assoc %extension%=%ftypename%

Some hints:

ftypename - FileType name can be random but should be unique.

extension - A filename extension. Examples of filename extensions are .png, .jpeg, .exe, .dmg

pathtoexe - Full executable path.

pathtoicon - Full path to icon or executable file with selected icon. If icon path empty then default icon from exe will be used. If want use custom icon change set pathtoicon="" for example to set pathtoicon="C:\icons\potato.ico".

Works atleast in Windows 7.

Solution 4

Adding Method #4:

  1. Right click on a file of the type you wish to change
  2. Click Open With... (select Choose Default Program... if a sub-menu appears)
  3. Select the application you wish to open this type of file with. You can also click the browse option if Windows doesn't suggest what you want.
  4. Ensure the box labeled Always use the selected program to open this type of file is ticked

Solution 5

I achieved the correct way of FILE ASSOCIATION using these cmd commands. this is just an example:

REG ADD "HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command" /v @ /t REG_SZ /d "\"C:\\Program Files\\Noteepad++\\notepad++.exe\" \"%1\"" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt" /v "Application" /t REG_SZ /d "notepad++.exe" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithList" /v "g" /t REG_SZ /d "notepad++.exe" /f

assoc .txt=MyCustomType
ftype MyCustomType="C:\Program Files\Noteepad++\notepad++.exe" "%1"

(it's better to put them in .bat file)

Share:
42,234
jdiaz
Author by

jdiaz

Updated on September 17, 2022

Comments

  • jdiaz
    jdiaz almost 2 years

    How do you associate a specific file type to an application on a Windows (Vista) PC?

    • Tony Stewart EE75
      Tony Stewart EE75 about 6 years
      It depends on .ext and as Windows has persistent associations in later OS Versions
  • gulbrandr
    gulbrandr over 13 years
    thanks. I just tried with "assoc .=MyCustomType" for files with no extension, and it worked!
  • Iulian Onofrei
    Iulian Onofrei about 10 years
    Something is wrong. Currently, .js files are opening with Sublime Text 2, and assoc .js command gives me .js=jsfile and ftype jsfile command gives me jsfile=%SystemRoot%\System32\WScript.exe "%1" %*.
  • RobH
    RobH almost 10 years
    You can add new files to the submenu this way without making them the default program. Just make sure the box mentioned in step 4 above is not ticked. (Note that there will be no "Open With..." item if the file doesn't currently have any programs associated with it.)
  • crazypotato
    crazypotato almost 10 years
    Creative Element Power Tools has been discontinued and is no longer supported. Instead use FileTypesMan
  • T.Todua
    T.Todua about 9 years
    If you run these commands from CMD, then use %1, but if you run .bat file, then use %%1
  • Scott - Слава Україні
    Scott - Слава Україні over 5 years
    (1) We frown on answers that merely summarize other answers. We do allow answers that build on previous answers, but you must identify the answer(s) that you are building on (by author’s name and link; not “the above”) and state the improvement you are making.  (2) What do you mean by “in .BAT file (NOT IN CMD)”?  (3) Every other example of an ftype command has %1 (or %%1) in quotes. Yours does not. Do you claim that your command is better because it leaves out the quotes? That would be rare.  Please do not respond in comments; edit your answer to make it clearer and more complete.
  • JGFMK
    JGFMK over 3 years
    What does this do? %%*
  • Admin
    Admin about 2 years